public void UpdateEntityDataLinkReports(EntityDataLinkReportDTO message) { BizEntityReport bizEntityReport = new MyModelManager.BizEntityReport(); using (var projectContext = new DataAccess.MyProjectEntities()) { var dbEntityDataLinkReport = projectContext.EntityDataLinkReport.FirstOrDefault(x => x.ID == message.ID); if (dbEntityDataLinkReport == null) { dbEntityDataLinkReport = new DataAccess.EntityDataLinkReport(); dbEntityDataLinkReport.EntityReport = bizEntityReport.ToNewEntityReport(message as EntityReportDTO, ReportType.DataLink); } else { bizEntityReport.ToUpdateEntityReport(dbEntityDataLinkReport.EntityReport, message as EntityReportDTO); } dbEntityDataLinkReport.EntityReport.Title = message.ReportTitle; dbEntityDataLinkReport.DataLinkDefinitionID = message.DataLinkID; //while (dbEntityDataLinkReport.EntityDataLinkReportSubs1.Any()) // projectContext.EntityDataLinkReportSubs.Remove(dbEntityDataLinkReport.EntityDataLinkReportSubs1.First()); //foreach (var sub in message.EntityDataLinkReportSubs) //{ // EntityDataLinkReportSubs rColumn = new EntityDataLinkReportSubs(); // rColumn.Title = sub.Title; // rColumn.ChildEntityDataLinkReportID = sub.EntityDataLinkReportID; // rColumn.OrderID = sub.OrderID; // rColumn.RelationshipID = sub.RelationshipID; // dbEntityDataLinkReport.EntityDataLinkReportSubs1.Add(rColumn); //} if (dbEntityDataLinkReport.ID == 0) { projectContext.EntityDataLinkReport.Add(dbEntityDataLinkReport); } projectContext.SaveChanges(); } }
public void UpdateEntityListReportGroupeds(EntityListReportGroupedDTO message) { using (var projectContext = new DataAccess.MyProjectEntities()) { BizEntityReport bizEntityReport = new MyModelManager.BizEntityReport(); var dbEntityListReportGrouped = projectContext.EntityListReportGrouped.FirstOrDefault(x => x.ID == message.ID); if (dbEntityListReportGrouped == null) { dbEntityListReportGrouped = new DataAccess.EntityListReportGrouped(); dbEntityListReportGrouped.EntityReport = bizEntityReport.ToNewEntityReport(message as EntityReportDTO, ReportType.ListReportGrouped); } else { bizEntityReport.ToUpdateEntityReport(dbEntityListReportGrouped.EntityReport, message as EntityReportDTO); } dbEntityListReportGrouped.EntityReport.Title = message.ReportTitle; dbEntityListReportGrouped.EntityListReportID = message.EntityListReportID; //while (dbEntityListReportGrouped.ReportGroups.Any()) // projectContext.ReportGroups.Remove(dbEntityListReportGrouped.ReportGroups.First()); //foreach (var sub in message.ReportGroups) //{ // ReportGroups rColumn = new ReportGroups(); // rColumn.EntityListViewColumnsID = sub.ListViewColumnID; // dbEntityListReportGrouped.ReportGroups.Add(rColumn); //} if (dbEntityListReportGrouped.ID == 0) { projectContext.EntityListReportGrouped.Add(dbEntityListReportGrouped); } projectContext.SaveChanges(); } }