Exemple #1
0
        private void ShowConfirmationCommandExecuted()
        {
            var appPath    = (string)ApplicationSettings.Read("DocumentsPath");
            var fileName   = string.Format("{0}_{1}_{2}", _event.Name, "Confirmation", DateTime.Now.ToString("g").Replace(":", "").Replace(@"/", ""));
            var reportPath = string.Concat(fileName, ".pdf");
            var exportPath = string.Concat(appPath, reportPath);

            var invoice = GetInvoice();

            // create a pdf file
            ReportingService.CreateConfirmationReport(invoice, exportPath);

            // store report in the database
            var report = new Report()
            {
                ID      = Guid.NewGuid(),
                EventID = _event.Event.ID,
                Date    = DateTime.Now,
                Name    = string.Format("Confirmation"),
                Path    = reportPath
            };

            _event.Reports.Add(new ReportModel(report));
            _eventDataUnit.ReportsRepository.Add(report);
            _event.RefreshReports();

            // update Updates table
            var update = new EventUpdate()
            {
                ID       = Guid.NewGuid(),
                EventID  = _event.Event.ID,
                Date     = DateTime.Now,
                UserID   = AccessService.Current.User.ID,
                Message  = "Event confirmation was created",
                OldValue = null,
                NewValue = report.Name,
                ItemId   = report.ID,
                ItemType = "EventReport",
                Field    = "ConfirmationReport",
                Action   = UpdateAction.Added
            };

            _event.EventUpdates.Insert(0, update);
            _eventDataUnit.EventUpdatesRepository.Add(update);

            var document = new Document()
            {
                ID        = report.ID,
                EventID   = _event.Event.ID,
                Path      = reportPath,
                Name      = Path.GetFileNameWithoutExtension(reportPath),
                IsEnabled = true,
                IsCommon  = false
            };

            _event.Documents.Add(document);
            _eventDataUnit.DocumentsRepository.Add(document);
        }