public async Task SetImportMovementReceiptAndRecoveryData(ImportMovementSummaryData data, Guid createdBy) { await context.Database.ExecuteSqlCommandAsync(@"[ImportNotification].[uspUpdateImportMovementData] @NotificationId ,@MovementId ,@PrenotificationDate ,@ActualDate ,@ReceiptDate ,@Quantity ,@Unit ,@RejectiontDate ,@RejectionReason ,@StatsMarking ,@Comments ,@RecoveryDate ,@CreatedBy", new SqlParameter("@NotificationId", data.Data.NotificationId), new SqlParameter("@MovementId", data.MovementId), new SqlParameter("@PrenotificationDate", (object)data.Data.PreNotificationDate ?? DBNull.Value), new SqlParameter("@ActualDate", (object)data.Data.ActualDate ?? DBNull.Value), new SqlParameter("@ReceiptDate", (object)data.ReceiptData.ReceiptDate ?? DBNull.Value), new SqlParameter("@Quantity", data.ReceiptData.ActualQuantity != null ? (object)decimal.Round(data.ReceiptData.ActualQuantity.Value, data.ReceiptData.ReceiptUnits != null ? ShipmentQuantityUnitsMetadata.Precision[data.ReceiptData.ReceiptUnits.Value] : ShipmentQuantityUnitsMetadata.Precision.Values.Min()) : DBNull.Value), new SqlParameter("@Unit", (object)data.ReceiptData.ReceiptUnits ?? DBNull.Value), new SqlParameter("@RejectiontDate", (object)data.RejectionDate ?? DBNull.Value), new SqlParameter("@RejectionReason", (object)data.ReceiptData.RejectionReason ?? DBNull.Value), new SqlParameter("@StatsMarking", (object)data.StatsMarking ?? DBNull.Value), new SqlParameter("@Comments", (object)data.Comments ?? DBNull.Value), new SqlParameter("@RecoveryDate", (object)data.RecoveryData.OperationCompleteDate ?? DBNull.Value), new SqlParameter("@CreatedBy", createdBy)); }
public CaptureViewModel(ImportMovementSummaryData data) { ShipmentNumber = data.Data.Number; ActualShipmentDate = new MaskedDateInputViewModel(data.Data.ActualDate.DateTime); if (data.Data.PreNotificationDate.HasValue) { PrenotificationDate = new MaskedDateInputViewModel(data.Data.PreNotificationDate.Value.DateTime); } else { PrenotificationDate = new MaskedDateInputViewModel(); HasNoPrenotification = true; } Comments = data.Comments; StatsMarking = data.StatsMarking; if (!string.IsNullOrWhiteSpace(data.Comments) || !string.IsNullOrWhiteSpace(data.StatsMarking)) { HasComments = true; } NotificationType = data.Data.NotificationType; IsReceived = data.IsReceived; IsOperationCompleted = data.RecoveryData.IsOperationCompleted; IsRejected = data.IsRejected; IsPartiallyRejected = data.IsPartiallyRejected; if (!data.IsReceived && !data.IsRejected && !data.IsPartiallyRejected) { data.IsReceived = true; } Receipt = new ReceiptViewModel { ActualQuantity = data.ReceiptData.ActualQuantity, ReceivedDate = data.ReceiptData.ReceiptDate.HasValue ? new MaskedDateInputViewModel(data.ReceiptData.ReceiptDate.Value.DateTime) : new MaskedDateInputViewModel(), ActualUnits = data.ReceiptData.ReceiptUnits ?? data.ReceiptData.NotificationUnit, ShipmentTypes = data.IsReceived ? ShipmentType.Accepted : (data.IsRejected ? ShipmentType.Rejected : ShipmentType.Partially), RejectionReason = data.ReceiptData.RejectionReason, PossibleUnits = data.ReceiptData.PossibleUnits, RejectedQuantity = data.RejectedQuantity, RejectedUnits = data.RejectedUnit }; Recovery = new RecoveryViewModel { NotificationType = data.Data.NotificationType, RecoveryDate = new MaskedDateInputViewModel(data.RecoveryData.OperationCompleteDate) }; }
public HomeViewModel(ImportMovementSummaryData movementSummaryData) { Id = movementSummaryData.Data.NotificationId; Number = movementSummaryData.Data.Number; NotificationId = movementSummaryData.Data.NotificationId; ActualShipmentDate = movementSummaryData.Data.ActualDate.DateTime; Receipt = new ReceiptViewModel(movementSummaryData.ReceiptData); Recovery = new RecoveryViewModel(movementSummaryData.RecoveryData.OperationCompleteDate, movementSummaryData.Data.NotificationType); IsReceived = movementSummaryData.ReceiptData.IsReceived; IsOperationCompleted = movementSummaryData.RecoveryData.IsOperationCompleted; if (movementSummaryData.Data.PreNotificationDate.HasValue) { PrenotificationDate = movementSummaryData.Data.PreNotificationDate.Value.DateTime; } }
public async Task <ActionResult> Index(Guid id, Guid movementId, IndexViewModel model) { if (!ModelState.IsValid) { await UpdateSummary(model, id); return(View(model)); } var data = new ImportMovementSummaryData { Data = new ImportMovementData { NotificationId = id, ActualDate = model.ActualShipmentDate.Value, PreNotificationDate = model.PrenotificationDate.HasValue ? model.PrenotificationDate.Value : (DateTime?)null }, ReceiptData = new ImportMovementReceiptData { ReceiptDate = (!model.IsRejected) && model.ReceivedDate.HasValue ? model.ReceivedDate.Value : (DateTime?)null, ActualQuantity = model.ActualQuantity, ReceiptUnits = model.Units, RejectionReason = model.RejectionReason, }, HasNoPrenotification = model.PrenotificationDate.HasValue ? false : true, RejectionDate = (model.IsRejected) && model.ReceivedDate.HasValue ? model.ReceivedDate.Value : (DateTime?)null, RecoveryData = new ImportMovementRecoveryData { OperationCompleteDate = model.Date.HasValue ? model.Date.Value : (DateTime?)null }, Comments = model.Comments, StatsMarking = model.StatsMarking, IsRejected = model.IsRejected, MovementId = movementId, RejectedQuantity = model.RejectedQuantity, RejectedUnit = model.RejectedUnits }; await mediator.SendAsync(new SetImportMovementReceiptAndRecoveryData(data)); await this.auditService.AddImportMovementAudit(this.mediator, id, model.ShipmentNumber, User.GetUserId(), MovementAuditType.Edited); return(RedirectToAction("Edit", "Capture", new { movementId })); }
public IndexViewModel(ImportMovementSummaryData data) { ShipmentNumber = data.Data.Number; ActualShipmentDate = data.Data.ActualDate.DateTime; if (data.Data.PreNotificationDate.HasValue) { PrenotificationDate = data.Data.PreNotificationDate.Value.DateTime; } else { HasNoPrenotification = true; } Comments = data.Comments; StatsMarking = data.StatsMarking; if (!string.IsNullOrWhiteSpace(data.Comments) || !string.IsNullOrWhiteSpace(data.StatsMarking)) { HasComments = true; } NotificationType = data.Data.NotificationType; IsReceived = data.ReceiptData.IsReceived; IsRejected = data.ReceiptData.IsRejected; IsOperationCompleted = data.RecoveryData.IsOperationCompleted; ActualQuantity = data.ReceiptData.ActualQuantity; ReceivedDate = data.ReceiptData.ReceiptDate.HasValue ? data.ReceiptData.ReceiptDate.Value.DateTime : (DateTime?)null; Units = data.ReceiptData.ReceiptUnits ?? data.ReceiptData.NotificationUnit; WasAccepted = string.IsNullOrWhiteSpace(data.ReceiptData.RejectionReason); RejectionReason = data.ReceiptData.RejectionReason; PossibleUnits = data.ReceiptData.PossibleUnits; IsPartiallyRejected = data.IsPartiallyRejected; RejectedQuantity = data.RejectedQuantity; RejectedUnits = data.RejectedUnit; NotificationType = data.Data.NotificationType; Date = data.RecoveryData.OperationCompleteDate.HasValue ? data.RecoveryData.OperationCompleteDate.Value : (DateTime?)null; if (!data.ReceiptData.IsReceived && !data.ReceiptData.IsRejected && !data.IsPartiallyRejected) { IsReceived = true; } }
public SetImportMovementReceiptAndRecoveryData(ImportMovementSummaryData data) { Data = data; }