public async Task <ActionResult> Upload(Guid notificationId) { var data = await mediator.SendAsync(new GetNotificationBasicInfo(notificationId)); var model = new ReceiptRecoveryBulkUploadViewModel(notificationId, data.NotificationType); return(View(model)); }
public void PostIndex_RedirectsToUpload() { var model = new ReceiptRecoveryBulkUploadViewModel(Guid.NewGuid(), type); var result = controller.Index(model.NotificationId, model) as RedirectToRouteResult; Assert.NotNull(result); Assert.Equal("Upload", (string)result.RouteValues["action"]); }
public async Task PostUpload_MissingFile_ReturnsView() { controller.ModelState.AddModelError("File", "Missing file"); var model = new ReceiptRecoveryBulkUploadViewModel(Guid.NewGuid(), type); var result = await controller.Upload(model.NotificationId, model) as ViewResult; Assert.NotNull(result); Assert.Equal(string.Empty, result.ViewName); }
public async Task GetUpload_ReturnsView() { var model = new ReceiptRecoveryBulkUploadViewModel(Guid.NewGuid(), type); model.File = A.Fake <HttpPostedFileBase>(); var result = await controller.Upload(Guid.NewGuid(), model) as ViewResult; Assert.NotNull(result); Assert.Equal("Documents", result.ViewName); }
public async Task <ActionResult> Upload(Guid notificationId, ReceiptRecoveryBulkUploadViewModel model) { var notificationType = (await mediator.SendAsync(new GetNotificationBasicInfo(notificationId))).NotificationType; model.NotificationType = notificationType; if (!ModelState.IsValid) { ViewBag.NotificationId = notificationId; model = new ReceiptRecoveryBulkUploadViewModel(notificationId, model.NotificationType); return(View(model)); } var validationSummary = await validator.GetValidationSummary(model.File, notificationId, User.GetAccessToken()); var failedFileRules = validationSummary.FileRulesResults.Where(r => r.MessageLevel == MessageLevel.Error).Select(r => r.Rule).ToList(); var failedContentRules = validationSummary.ContentRulesResults.Where(r => r.MessageLevel == MessageLevel.Error).ToList(); model.FailedFileRules = failedFileRules; model.FailedContentRules = failedContentRules; var shipments = validationSummary.ShipmentNumbers != null?validationSummary.ShipmentNumbers.ToList() : null; var data = await mediator.SendAsync(new GetNotificationBasicInfo(notificationId)); var shipmentsModel = new ShipmentMovementDocumentsViewModel(notificationId, shipments, model.File.FileName, data.NotificationType); if (model.ErrorsCount > 0) { return(View("Errors", model)); } TempData["PrenotificationShipments"] = shipments; TempData["PreNotificationFileName"] = model.File.FileName; TempData["DraftBulkUploadId"] = validationSummary.DraftBulkUploadId; return(View("Documents", shipmentsModel)); }
public ActionResult Index(Guid notificationId, ReceiptRecoveryBulkUploadViewModel model) { return(RedirectToAction("Upload")); }