changes: Fix dashboard widgets relationship
This commit is contained in:
@@ -12,6 +12,7 @@ namespace SplashPage.Splash
|
||||
Task<bool> SaveDashboard(int dashboardId, List<SplashWidgetDto> widgets);
|
||||
Task<List<SplashDashboardDto>> GetDashboards();
|
||||
Task<SplashDashboard> CreateDashboard(CreateSplashDashboardDto model);
|
||||
|
||||
Task<bool> UpdateDashboard(UpdateSplashDashboardDto model);
|
||||
Task<SplashDashboardDto> DuplicateDashboard(DuplicateSplashDashboardDto model);
|
||||
[HttpDelete]
|
||||
|
||||
@@ -14,6 +14,7 @@ using System.Threading.Tasks;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using Abp.Authorization;
|
||||
using SplashPage.Authorization;
|
||||
using Abp.EntityFrameworkCore.Repositories;
|
||||
|
||||
namespace SplashPage.Splash
|
||||
{
|
||||
@@ -25,6 +26,7 @@ namespace SplashPage.Splash
|
||||
private readonly IRepository<SplashAccessPoint> _splashAccessPointRepository;
|
||||
private readonly IRepository<SplashNetworkGroup> _networkGroupRepository;
|
||||
private readonly IRepository<SplashNetworkGroupMember> _networkGroupMemberRepository;
|
||||
private readonly IRepository<SplashWidget> _widgetRepository;
|
||||
private readonly SplashNetworkGroupManager _networkGroupManager;
|
||||
private readonly IUnitOfWorkManager _unitOfWorkManager;
|
||||
public SplashDashboardService(IRepository<SplashDashboard> splashDashboardRepository,
|
||||
@@ -33,7 +35,8 @@ namespace SplashPage.Splash
|
||||
IRepository<SplashAccessPoint> splashAccessPointRepository,
|
||||
IRepository<SplashNetworkGroup> networkGroupRepository,
|
||||
IRepository<SplashNetworkGroupMember> networkGroupMemberRepository,
|
||||
SplashNetworkGroupManager networkGroupManager)
|
||||
SplashNetworkGroupManager networkGroupManager
|
||||
, IRepository<SplashWidget> widgetRepository)
|
||||
{
|
||||
_splashDashboardRepository = splashDashboardRepository;
|
||||
_unitOfWorkManager = unitOfWorkManager;
|
||||
@@ -42,6 +45,7 @@ namespace SplashPage.Splash
|
||||
_networkGroupRepository = networkGroupRepository;
|
||||
_networkGroupMemberRepository = networkGroupMemberRepository;
|
||||
_networkGroupManager = networkGroupManager;
|
||||
_widgetRepository = widgetRepository;
|
||||
}
|
||||
|
||||
//[AbpAuthorize(PermissionNames.Pages_Dashboards_Create)]
|
||||
@@ -833,7 +837,9 @@ namespace SplashPage.Splash
|
||||
throw new Abp.UI.UserFriendlyException($"Dashboard with ID {dashboardId} not found");
|
||||
}
|
||||
|
||||
await _widgetRepository.BatchDeleteAsync(x => x.DashboardId == dashboardId);
|
||||
await _splashDashboardRepository.DeleteAsync(dashboard);
|
||||
CurrentUnitOfWork.SaveChanges();
|
||||
Logger.Info($"DeleteDashboard: Successfully deleted dashboard with ID {dashboardId}");
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace SplashPage.Splash
|
||||
SelectedNetworks = selectedNetworks;
|
||||
StartDate = DateTime.UtcNow;
|
||||
EndDate = DateTime.UtcNow.AddDays(-1);
|
||||
Widgets= new List<SplashWidget>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ namespace SplashPage.Splash
|
||||
public int WidgetType { get; set; }
|
||||
public string Content { get; set; }
|
||||
|
||||
public int DashboardId { get; set; }
|
||||
public SplashDashboard Dashboard { get; set; }
|
||||
|
||||
//Implementations
|
||||
public DateTime CreationTime { get; set; }
|
||||
public int TenantId { get; set; }
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using SplashPage.Splash;
|
||||
|
||||
namespace SplashPage.Configurations
|
||||
{
|
||||
public class SplashWidgetConfiguration : IEntityTypeConfiguration<SplashWidget>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<SplashWidget> builder)
|
||||
{
|
||||
builder.ToTable("SplashWidgets");
|
||||
|
||||
builder.Property(x => x.Id)
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
builder.Property(x => x.DashboardId)
|
||||
.HasColumnName("SplashDashboardId");
|
||||
|
||||
builder.HasOne(x => x.Dashboard)
|
||||
.WithMany(x => x.Widgets)
|
||||
.HasForeignKey(x => x.DashboardId);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user