public async Task SiteOfExport_BackToListFalse_BackToOverviewNull_ReturnsImporterIndex() { var model = new SiteOfExportViewModel { NotificationId = notificationId, SelectedSiteOfExport = producerId }; var result = await producerController.SiteOfExport(model, false, null) as RedirectToRouteResult; RouteAssert.RoutesTo(result.RouteValues, "Index", "Importer"); }
public async Task SiteOfExport_BackToListTrue_IgnoresBackToOverview(bool?backToOverview) { var model = new SiteOfExportViewModel { NotificationId = notificationId, SelectedSiteOfExport = producerId }; var result = await producerController.SiteOfExport(model, true, backToOverview) as RedirectToRouteResult; Assert.Equal("List", result.RouteValues["action"]); }
public async Task SiteOfExport_Post_CallsClient() { var model = new SiteOfExportViewModel { NotificationId = notificationId, SelectedSiteOfExport = producerId }; await producerController.SiteOfExport(model, null); A.CallTo( () => mediator.SendAsync(A <SetSiteOfExport> .That.Matches(p => p.NotificationId == notificationId && p.ProducerId == producerId))) .MustHaveHappened(Repeated.Exactly.Once); }
public async Task <ActionResult> SiteOfExport(Guid id, bool?backToList, bool?backToOverview = null) { ViewBag.BackToOverview = backToOverview.GetValueOrDefault(); var response = await mediator.SendAsync(new GetProducersByNotificationId(id)); var model = new SiteOfExportViewModel { NotificationId = id, Producers = response }; return(View(model)); }
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 SiteOfExport_BackToListFalse_BackToOverviewNull_ReturnsImporterIndex() { var model = new SiteOfExportViewModel { NotificationId = notificationId, SelectedSiteOfExport = producerId }; var result = await producerController.SiteOfExport(model, false, null) as RedirectToRouteResult; RouteAssert.RoutesTo(result.RouteValues, "Index", "Importer"); }
public async Task SiteOfExport_BackToListTrue_IgnoresBackToOverview(bool? backToOverview) { var model = new SiteOfExportViewModel { NotificationId = notificationId, SelectedSiteOfExport = producerId }; var result = await producerController.SiteOfExport(model, true, backToOverview) as RedirectToRouteResult; Assert.Equal("List", result.RouteValues["action"]); }
public async Task SiteOfExport_Post_CallsClient() { var model = new SiteOfExportViewModel { NotificationId = notificationId, SelectedSiteOfExport = producerId }; await producerController.SiteOfExport(model, null); A.CallTo( () => mediator.SendAsync(A<SetSiteOfExport>.That.Matches(p => p.NotificationId == notificationId && p.ProducerId == producerId))) .MustHaveHappened(Repeated.Exactly.Once); }
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); } await mediator.SendAsync(new SetSiteOfExport( model.SelectedSiteOfExport.GetValueOrDefault(), model.NotificationId)); 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<ActionResult> SiteOfExport(Guid id, bool? backToList, bool? backToOverview = null) { ViewBag.BackToOverview = backToOverview.GetValueOrDefault(); var response = await mediator.SendAsync(new GetProducersByNotificationId(id)); var model = new SiteOfExportViewModel { NotificationId = id, Producers = response }; return View(model); }