public async Task <ActionResult> Index(Guid notificationId, Guid movementId, ReceiptRecoveryViewModel model) { if (!ModelState.IsValid) { return(View(model)); } TempData[CertificateKey] = model.Certificate; TempData[NotificationTypeKey] = model.NotificationType; MovementBasicDetails movementDetails = await mediator.SendAsync(new GetMovementDetailsById(notificationId, movementId)); ValidateShipment(model.GetDateReceived(), movementDetails); if (!ModelState.IsValid) { return(View(model)); } TempData[DateReceivedKey] = model.GetDateReceived(); TempData[UnitKey] = model.Unit; TempData[QuantityKey] = model.Quantity; TempData[DateRecoveredKey] = model.GetDateRecovered(); var shipmentExists = await mediator.SendAsync(new DoesMovementDetailsExist(movementId)); if (shipmentExists) { var tolerance = await mediator.SendAsync(new DoesQuantityReceivedExceedTolerance(movementId, Convert.ToDecimal(model.Quantity), model.Unit)); if (tolerance == QuantityReceivedTolerance.AboveTolerance || tolerance == QuantityReceivedTolerance.BelowTolerance) { TempData[ToleranceKey] = tolerance; return(RedirectToAction("QuantityAbnormal", new { movementId = movementId })); } } return(RedirectToAction("UploadCertificate", new { movementId = movementId })); }
public async Task <ActionResult> Index(Guid notificationId, Guid movementId) { var movementDetails = await mediator.SendAsync(new GetMovementDetailsById(notificationId, movementId)); var model = new ReceiptRecoveryViewModel { SelectedmovementId = movementId, NotificationId = notificationId, NotificationType = await mediator.SendAsync(new GetNotificationType(notificationId)), Unit = await mediator.SendAsync(new GetShipmentUnits(notificationId)), ShipmentNumber = movementDetails.Number }; if (TempData[CertificateKey] != null) { model.Certificate = (CertificateType)TempData[CertificateKey]; } else { return(RedirectToAction("CertificateTypes", "Certificate")); } return(View(model)); }