Пример #1
0
        /// <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();
        }
Пример #2
0
        /// <summary>
        /// Remove all items referenced by the delete preview.
        /// This method is not publically exposed to ensure nothing outside the
        /// class can invoke this method to get around permissions.
        /// </summary>
        private void ExecuteDeletePreview(DeletePreview preview)
        {
            // Clean up the reports
            preview.Reports.ForEach(r =>
            {
                var report = _reportsUoW.Find <Report>(r.Id, TrackingMode.Automatic, ThrowIf.Nothing);
                if (report == null)
                {
                    return;
                }

                DeleteReport(report);
            });

            // Clean up summaries
            preview.Summaries.ForEach(s =>
            {
                var summary = _summaryUoW.Find <Summary>(s.Id, TrackingMode.Automatic, ThrowIf.Nothing);
                if (summary == null)
                {
                    return;
                }

                DeleteSummary(summary);
            });

            // Clean up Cases
            preview.Cases.ForEach(c =>
            {
                var cCase = _summaryUoW.Find <Domain.Summaries.Case.Case>(c.CaseId, TrackingMode.Automatic, ThrowIf.Nothing);
                if (cCase == null)
                {
                    return;
                }
                _summaryUoW.Remove(cCase);
                _summaryUoW.PendingMessages.Add(new CaseDeletedMessage(IdentityId, cCase.Id, ModuleType.Case));
            });

            // Commit the changes
            _reportsUoW.Commit();
            _summaryUoW.Commit();
        }