public Guid AddAttachmentToSummary(Attachment attachment, Guid summaryId) { // Load the Summary. var summary = _sumUoW.Find <Summary>(summaryId); // TODO: Check permissions once we determine module type. // Construct the Entity. var entity = new SummaryAttachment(IdentityId, summary.AgencyId, attachment.Id); // Map into the summary-specific type. attachment.MapInto(entity); // Add the attachment. summary.Attachments.Add(entity); _sumUoW.Commit(); // TODO: Hack until the Surrogate Keys are introduced in the Data layer. // TODO: Currently the Event messages will get the wrong Id unless they are raised AFTER the database commit // TODO: because the database may override the Guid the Domain is trying to use. _sumUoW.PendingMessages.Add(DataEntryMessages.EntityCreated(entity, summary.ModuleType, DataEntryAggregateType.Summary)); _sumUoW.PublishPendingMessages(); return(entity.Id); }
/// <summary> /// Create a new Entity on a Report. /// </summary> protected TEntity CreateReportEntity <TEntity, TEntityDetails>(Guid reportId, TEntityDetails details, EntityConstructor <TEntity> constructor, Action <TReport, TEntity> add) where TEntityDetails : IPublicSafetyEntityDetails where TEntity : PublicSafetyEntity { // Load the Report var report = UnitOfWork.Find <TReport>(reportId); // Check Permissions RequireCreatePermissions(report.AgencyId, ReportModule); // Construct the Entity var entity = constructor(report.AgencyId, details.Id); // Map the Entity Details details.MapInto(entity); // Add the Entity to the Report add(report, entity); // Commit the Work UnitOfWork.Commit(); // TODO: Hack until the Surrogate Keys are introduced in the Data layer. // TODO: Currently the Event messages will get the wrong Id unless they are raised AFTER the database commit // TODO: because the database may override the Guid the Domain is trying to use. UnitOfWork.PendingMessages.Add(DataEntryMessages.EntityCreated(entity, ReportModule, DataEntryAggregateType.Report)); UnitOfWork.PublishPendingMessages(); return(entity); }
protected TEntity CreateSummaryEntity <TEntity, TEntityDetails>(Guid summaryId, TEntityDetails details, EntityConstructor <TEntity> constructor, Action <TSummary, TEntity> add) where TEntityDetails : IPublicSafetyEntityDetails where TEntity : PublicSafetyEntity { var summary = UnitOfWork.Find <TSummary>(summaryId); RequireViewPermissions(summary.AgencyId, SummaryModule); var entity = constructor(summary.AgencyId, details.Id); details.MapInto(entity); add(summary, entity); _masterIndexService.ProcessMasterIndexes(entity); UnitOfWork.Commit(); // TODO: Hack until the Surrogate Keys are introduced in the Data layer. // TODO: Currently the Event messages will get the wrong Id unless they are raised AFTER the database commit // TODO: because the database may override the Guid the Domain is trying to use. UnitOfWork.PendingMessages.Add(DataEntryMessages.EntityCreated(entity, SummaryModule, DataEntryAggregateType.Summary)); UnitOfWork.PublishPendingMessages(); return(entity); }
/// <summary> /// Removes the given Attachment from the given Summary. /// </summary> public void DisassociateSummaryAttachment(Guid attachmentId) { var entity = _sumUoW.Find <SummaryAttachment>(attachmentId); // TODO: Check permissions once we determine module type. _sumUoW.Remove(entity); _sumUoW.PendingMessages.Add( DataEntryMessages.EntityDeleted(IdentityId, entity, ModuleType.Unset, DataEntryAggregateType.Summary)); _sumUoW.Commit(); }
/// <summary> /// Updates the given Report attachment. /// </summary> public void UpdateReportAttachment(Attachment attachment) { var entity = _rptUoW.Find <ReportAttachment>(attachment.Id); attachment.MapInto(entity); _rptUoW.Commit(); // TODO: Hack until the Surrogate Keys are introduced in the Data layer. // TODO: Currently the Event messages will get the wrong Id unless they are raised AFTER the database commit // TODO: because the database may override the Guid the Domain is trying to use. _rptUoW.PendingMessages.Add(DataEntryMessages.EntityModified(entity, ModuleType.Unset, DataEntryAggregateType.Report)); _rptUoW.PublishPendingMessages(); }
protected void Delete <TEntity>(Guid id) where TEntity : PublicSafetyEntity { var entity = UnitOfWork.Find <TEntity>(id); entity.SetModified(IdentityId); UnitOfWork.Remove(entity); UnitOfWork.Commit(); // TODO: Hack until the Surrogate Keys are introduced in the Data layer. // TODO: Currently the Event messages will get the wrong Id unless they are raised AFTER the database commit // TODO: because the database may override the Guid the Domain is trying to use. UnitOfWork.PendingMessages.Add(DataEntryMessages.EntityDeleted(IdentityId, entity, ReportModule, DataEntryAggregateType.Report)); UnitOfWork.PublishPendingMessages(); }
protected TEntity Update <TEntity, TEntityDetails>(TEntityDetails details) where TEntity : PublicSafetyEntity where TEntityDetails : IPublicSafetyEntityDetails { var entity = UnitOfWork.Find <TEntity>(details.Id); RequireCreatePermissions(entity.AgencyId, ReportModule); details.MapInto(entity); entity.SetModified(IdentityId); UnitOfWork.Commit(); // TODO: Hack until the Surrogate Keys are introduced in the Data layer. // TODO: Currently the Event messages will get the wrong Id unless they are raised AFTER the database commit // TODO: because the database may override the Guid the Domain is trying to use. UnitOfWork.PendingMessages.Add(DataEntryMessages.EntityModified(entity, ReportModule, DataEntryAggregateType.Report)); UnitOfWork.PublishPendingMessages(); return(entity); }
/// <summary> /// Add the PDF to Report and Summary /// </summary> public void AttachOfficerReport(Attachment attachment, Report report, Summary summary) { //todo: Enable MSDTC? var reportAttachment = new ReportAttachment(report.CreatedBy, report.AgencyId, attachment.Id); attachment.MapInto(reportAttachment); report.Attachments.Add(reportAttachment); _rptUoW.Commit(); var summaryAttachment = new SummaryAttachment(summary.CreatedBy, summary.AgencyId, attachment.Id); attachment.MapInto(summaryAttachment); summary.Attachments.Add(summaryAttachment); _summariesUnitOfWork.Commit(); // Raise a message indicating that the report has been attached to the summary. _summariesUnitOfWork.PendingMessages.Add(DataEntryMessages.EntityCreated(summaryAttachment, summary.ModuleType, DataEntryAggregateType.Summary)); _summariesUnitOfWork.PublishPendingMessages(); }
public Guid AddAttachmentToReport(Attachment attachment, Guid reportId) { // Load the Report. var report = _rptUoW.Find <Report>(reportId); // TODO: Check permissions once we determine module type. // Create the Attachment var entity = new ReportAttachment(IdentityId, report.AgencyId, attachment.Id); attachment.MapInto(entity); report.Attachments.Add(entity); _rptUoW.Commit(); // TODO: Hack until the Surrogate Keys are introduced in the Data layer. // TODO: Currently the Event messages will get the wrong Id unless they are raised AFTER the database commit // TODO: because the database may override the Guid the Domain is trying to use. _rptUoW.PendingMessages.Add(DataEntryMessages.EntityCreated(entity, report.ModuleType, DataEntryAggregateType.Report)); _rptUoW.PublishPendingMessages(); return(entity.Id); }