Beispiel #1
0
 private async Task AddAuditData(Guid id, NotificationAuditType type, NotificationAuditScreenType screen)
 {
     await this.auditService.AddAuditEntry(this.mediator,
                                           id,
                                           User.GetUserId(),
                                           type,
                                           screen);
 }
Beispiel #2
0
        public async Task <ActionResult> Index(Guid id, CustomsOfficeViewModel model, bool?backToOverview = null)
        {
            var countries = await mediator.SendAsync(new GetEuropeanUnionCountries());

            model.Countries = model.SelectedCountry.HasValue
                ? new SelectList(countries, "Id", "Name", model.SelectedCountry.Value)
                : new SelectList(countries, "Id", "Name");

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var existingData = await mediator.SendAsync(new GetExitCustomsOfficeAddDataByNotificationId(id));

            NotificationAuditType auditType = NotificationAuditType.Added;

            if (model.CustomsOfficeRequired.GetValueOrDefault())
            {
                await mediator.SendAsync(
                    new SetExitCustomsOfficeForNotificationById(id,
                                                                model.Name,
                                                                model.Address,
                                                                model.SelectedCountry.Value));

                auditType = existingData.CustomsOfficeData == null ? NotificationAuditType.Added : NotificationAuditType.Updated;
            }
            else if (existingData.CustomsOfficeData != null)
            {
                // If customs office required is set to false but there is existing data in the database, delete it
                await mediator.SendAsync(new DeleteExitCustomsOfficeByNotificationId(id));

                auditType = NotificationAuditType.Deleted;
            }

            await this.auditService.AddAuditEntry(this.mediator,
                                                  id,
                                                  User.GetUserId(),
                                                  auditType,
                                                  NotificationAuditScreenType.CustomsOffice);

            var addSelection = await mediator.SendAsync(new SetExitCustomsOfficeSelectionForNotificationById(id, model.CustomsOfficeRequired.GetValueOrDefault()));

            var notificationCompetentAutority = await mediator.SendAsync(new GetNotificationCompetentAuthority(id));

            if (notificationCompetentAutority.Equals(UKCompetentAuthority.NorthernIreland))
            {
                return(RedirectToAction("Index", "EntryCustomsOffice", new { id, backToOverview = backToOverview }));
            }

            if (backToOverview.GetValueOrDefault())
            {
                return(RedirectToAction("Index", "Home", new { id }));
            }

            return(RedirectToAction("Index", "Shipment", new { id }));
        }
Beispiel #3
0
        public async Task <ActionResult> SiteOfTreatment(SiteOfTreatmentViewModel model, bool?backToList,
                                                         bool?backToOverview = null)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }

                var existingFacilities = await mediator.SendAsync(new GetFacilitiesByNotificationId(model.NotificationId));

                await
                mediator.SendAsync(
                    new SetActualSiteOfTreatment(model.SelectedSiteOfTreatment.GetValueOrDefault(),
                                                 model.NotificationId));

                NotificationAuditType type = NotificationAuditType.Added;

                if (existingFacilities != null && existingFacilities.Count(p => p.IsActualSiteOfTreatment) > 0)
                {
                    type = NotificationAuditType.Updated;
                }

                await this.auditService.AddAuditEntry(mediator,
                                                      model.NotificationId,
                                                      User.GetUserId(),
                                                      type,
                                                      model.NotificationType == NotificationType.Disposal?NotificationAuditScreenType.DisposalSite : NotificationAuditScreenType.RecoverySite);

                if (backToList.GetValueOrDefault())
                {
                    return(RedirectToAction("List", "Facility", new { id = model.NotificationId, backToOverview }));
                }
                if (backToOverview.GetValueOrDefault())
                {
                    return(RedirectToAction("Index", "Home", new { id = model.NotificationId }));
                }
                if (model.NotificationType == NotificationType.Recovery)
                {
                    return(RedirectToAction("RecoveryPreconsent", "Facility", new { id = model.NotificationId }));
                }
                return(RedirectToAction("OperationCodes", "WasteOperations", new { id = model.NotificationId }));
            }
            catch (ApiBadRequestException ex)
            {
                this.HandleBadRequest(ex);

                if (ModelState.IsValid)
                {
                    throw;
                }
            }

            return(View(model));
        }
        public async Task SaveChangesAsync(NotificationAuditType auditType = NotificationAuditType.Edited,
                                           string auditUserOverride        = null)
        {
            _context.AddAuditCustomField(CustomFields.AuditDetails, auditType);
            if (auditUserOverride != null)
            {
                _context.AddAuditCustomField(CustomFields.OverrideUser, auditUserOverride);
            }

            await _context.SaveChangesAsync();
        }
 public async Task AuditNotificationReadAsync(int notificationId, NotificationAuditType auditDetails,
                                              string userName)
 {
     var notificationIdString = notificationId.ToString();
     await _auditContext.AuditOperationAsync(
         notificationIdString,
         RootEntities.Notification,
         auditDetails.ToString(),
         READ_EVENT,
         userName,
         RootEntities.Notification,
         notificationIdString);
 }
Beispiel #6
0
        public async Task AddAuditEntry(IMediator mediator,
                                        Guid notificationId,
                                        string userId,
                                        NotificationAuditType auditType,
                                        NotificationAuditScreenType screenType)
        {
            var audit = CreateAudit(notificationId,
                                    userId,
                                    screenType,
                                    auditType);

            await mediator.SendAsync(audit);
        }
 public async Task AuditMatchSpecimen(int notificationId,
                                      string labReferenceNumber,
                                      string userName,
                                      NotificationAuditType auditType)
 {
     await _auditContext.AuditOperationAsync(
         labReferenceNumber,
         SPECIMEN_ENTITY_TYPE,
         auditType.ToString(),
         MATCH_EVENT,
         userName,
         RootEntities.Notification,
         notificationId.ToString());
 }
 public async Task AuditRejectPotentialSpecimen(int notificationId,
                                                string labReferenceNumber,
                                                string userName,
                                                NotificationAuditType auditType)
 {
     await _auditContext.AuditOperationAsync(
         labReferenceNumber,
         SPECIMEN_ENTITY_TYPE,
         auditType.ToString(),
         AuditEventType.REJECT_POTENTIAL,
         userName,
         RootEntities.Notification,
         notificationId.ToString());
 }
Beispiel #9
0
 private static CreateNotificationAudit CreateAudit(Guid notificationId,
                                                    string userId,
                                                    NotificationAuditScreenType screen,
                                                    NotificationAuditType type)
 {
     return(new CreateNotificationAudit()
     {
         DateAdded = SystemTime.Now,
         NotificationId = notificationId,
         UserId = userId,
         Screen = screen,
         Type = type
     });
 }
Beispiel #10
0
        public async Task <ActionResult> SiteOfExport(SiteOfExportViewModel model,
                                                      bool?backToList,
                                                      bool?backToOverview = null)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.BackToOverview = backToOverview.GetValueOrDefault();

                var response = await mediator.SendAsync(new GetProducersByNotificationId(model.NotificationId));

                model.Producers = response;

                return(View(model));
            }

            var existingProducers =
                await mediator.SendAsync(new GetProducersByNotificationId(model.NotificationId));

            await mediator.SendAsync(new SetSiteOfExport(
                                         model.SelectedSiteOfExport.GetValueOrDefault(),
                                         model.NotificationId));

            NotificationAuditType type = NotificationAuditType.Added;

            if (existingProducers != null && existingProducers.Count(p => p.IsSiteOfExport) > 0)
            {
                type = NotificationAuditType.Updated;
            }

            await this.auditService.AddAuditEntry(mediator,
                                                  model.NotificationId,
                                                  User.GetUserId(),
                                                  type,
                                                  NotificationAuditScreenType.SiteOfExport);

            if (backToList.GetValueOrDefault())
            {
                return(RedirectToAction("List", "Producer", new { id = model.NotificationId, backToOverview }));
            }

            if (backToOverview.GetValueOrDefault())
            {
                return(RedirectToAction("Index", "Home", new { id = model.NotificationId }));
            }

            return(RedirectToAction("Index", "Importer", new { id = model.NotificationId }));
        }
 public async Task SaveChangesAsync(NotificationAuditType auditDetails = NotificationAuditType.Edited)
 {
     _context.AddAuditCustomField(CustomFields.AuditDetails, auditDetails);
     await _context.SaveChangesAsync();
 }