Exemplo n.º 1
0
        public static NotificationManageViewModel ToNotificationManageViewModel(IEnumerable <NotificationType> notificationTypes, int?type, int?to, string language)
        {
            var model = new NotificationManageViewModel();
            NotificationTypeViewModel   typeViewModel = new NotificationTypeViewModel();
            List <NotificationTypeList> typeList      = new List <NotificationTypeList>();

            model.Addresses = new List <AddressViewModel>();
            foreach (var notificationType in notificationTypes)
            {
                if ((int)notificationType.NotificationCategory == type)
                {
                    typeViewModel = new NotificationTypeViewModel
                    {
                        Id    = notificationType.Id,
                        Label = notificationType.Label,
                        NotificationTypeSettingId = notificationType.NotificationTypeSettingId,
                        Category = notificationType.NotificationCategory
                    };
                    model.Addresses = ToAddressViewModels(notificationType, to);
                }
                typeList.Add(new NotificationTypeList
                {
                    Id          = (int)notificationType.NotificationCategory,
                    Label       = notificationType.Label,
                    Description = GetNotificationTypeLabelDescription(notificationType.Label, language)
                });
            }
            model.NotificationTypeViewModel = typeViewModel;
            model.NotificationTypeList      = typeList;
            return(model);
        }
 private NotificationTypeDto MapNotificationType(NotificationTypeViewModel notification)
 {
     switch (notification)
     {
         case NotificationTypeViewModel.Daily: return NotificationTypeDto.Daily;
         case NotificationTypeViewModel.Weekly: return NotificationTypeDto.Weekly;
         case NotificationTypeViewModel.Monthly: return NotificationTypeDto.Monthly;
         default: return NotificationTypeDto.Daily;
     }
 }
Exemplo n.º 3
0
        public async Task NotificationTypeQuestion_Post_RedirectsToCorrectAction()
        {
            var controller = CreateNewNotificationController();
            var model      = new NotificationTypeViewModel();

            model.SelectedNotificationType = NotificationType.Recovery;
            var result = await controller.NotificationType(model, null) as RedirectToRouteResult;

            Assert.Equal("Created", result.RouteValues["action"]);
        }
Exemplo n.º 4
0
        public async Task NotificationTypeQuestion_PostInvalidModel_ReturnsToCorrectView()
        {
            var controller = CreateNewNotificationController();

            controller.ModelState.AddModelError("Error", "Test Error");
            var model  = new NotificationTypeViewModel();
            var result = await controller.NotificationType(model, null) as ViewResult;

            Assert.Empty(result.ViewName);
            Assert.IsType <NotificationTypeViewModel>(result.Model);
        }
Exemplo n.º 5
0
        public ActionResult NotificationType(NotificationTypeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            TempData[SelectedCompetentAuthority] = model.CompetentAuthority;
            TempData[SelectedNotificationType]   = model.SelectedNotificationType.GetValueOrDefault();

            return(RedirectToAction("NewOrExistingNotification"));
        }
        public ActionResult NotificationType(NotificationTypeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            TempData[SelectedCompetentAuthority] = model.CompetentAuthority;
            TempData[SelectedNotificationType] = model.SelectedNotificationType.GetValueOrDefault();

            return RedirectToAction("NewOrExistingNotification");
        }
Exemplo n.º 7
0
        public ActionResult NotificationType(string ca, string nt)
        {
            var model = new NotificationTypeViewModel
            {
                CompetentAuthority = ca.GetValueFromDisplayName <UKCompetentAuthority>()
            };

            if (!string.IsNullOrWhiteSpace(nt))
            {
                model.SelectedNotificationType = nt.GetValueFromDisplayName <NotificationType>();
            }

            return(View(model));
        }
        public ActionResult NotificationType(string ca, string nt)
        {
            var model = new NotificationTypeViewModel
            {
                CompetentAuthority = ca.GetValueFromDisplayName<UKCompetentAuthority>()
            };

            if (!string.IsNullOrWhiteSpace(nt))
            {
                model.SelectedNotificationType = nt.GetValueFromDisplayName<NotificationType>();
            }

            return View(model);
        }
        public async Task <ActionResult> NotificationType(NotificationTypeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var notificationType = (NotificationType)model.NotificationTypeRadioButtons.SelectedValue;

            var id = await mediator.SendAsync(new CreateImportNotification(model.NotificationNumber, notificationType, model.ReceivedDate, model.IsInterim));

            if (notificationType == Core.Shared.NotificationType.Disposal)
            {
                return(RedirectToAction("Index", "Exporter", new { area = "ImportNotification", id }));
            }

            return(RedirectToAction("Index", "Preconsented", new { area = "ImportNotification", id }));
        }
Exemplo n.º 10
0
        public async Task <ActionResult> NotificationType(NotificationTypeViewModel model, string cfp)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                var response =
                    await
                    mediator.SendAsync(
                        new CreateNotificationApplication
                {
                    CompetentAuthority = model.CompetentAuthority,
                    NotificationType   = model.SelectedNotificationType.Value
                });

                return(RedirectToAction("Created",
                                        new
                {
                    id = response,
                    cfp
                }));
            }
            catch (ApiBadRequestException ex)
            {
                this.HandleBadRequest(ex);

                if (ModelState.IsValid)
                {
                    throw;
                }
            }

            return(View(model));
        }
        public async Task<ActionResult> NotificationType(NotificationTypeViewModel model, string cfp)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            try
            {
                var response =
                    await
                        mediator.SendAsync(
                            new CreateNotificationApplication
                            {
                                CompetentAuthority = model.CompetentAuthority,
                                NotificationType = model.SelectedNotificationType.Value
                            });

                return RedirectToAction("Created",
                    new
                    {
                        id = response,
                        cfp
                    });
            }
            catch (ApiBadRequestException ex)
            {
                this.HandleBadRequest(ex);

                if (ModelState.IsValid)
                {
                    throw;
                }
            }

            return View(model);
        }
        public async Task NotificationTypeQuestion_Post_RedirectsToCorrectAction()
        {
            var controller = CreateNewNotificationController();
            var model = new NotificationTypeViewModel();
            model.SelectedNotificationType = NotificationType.Recovery;
            var result = await controller.NotificationType(model, null) as RedirectToRouteResult;

            Assert.Equal("Created", result.RouteValues["action"]);
        }
        public async Task NotificationTypeQuestion_PostInvalidModel_ReturnsToCorrectView()
        {
            var controller = CreateNewNotificationController();
            controller.ModelState.AddModelError("Error", "Test Error");
            var model = new NotificationTypeViewModel();
            var result = await controller.NotificationType(model, null) as ViewResult;

            Assert.Empty(result.ViewName);
            Assert.IsType<NotificationTypeViewModel>(result.Model);
        }
        public async Task<ActionResult> NotificationType(NotificationTypeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            var notificationType = (NotificationType)model.NotificationTypeRadioButtons.SelectedValue;

            var id = await mediator.SendAsync(new CreateImportNotification(model.NotificationNumber, notificationType, model.ReceivedDate, model.IsInterim));

            if (notificationType == Core.Shared.NotificationType.Disposal)
            {
                return RedirectToAction("Index", "Exporter", new { area = "ImportNotification", id });
            }

            return RedirectToAction("Index", "Preconsented", new { area = "ImportNotification", id });
        }