Beispiel #1
0
        public CaptureViewModel(MovementReceiptAndRecoveryData data)
        {
            ActualShipmentDate = new MaskedDateInputViewModel(data.ActualDate);
            if (data.PrenotificationDate.HasValue)
            {
                PrenotificationDate = new MaskedDateInputViewModel(data.PrenotificationDate.Value);
            }
            else
            {
                PrenotificationDate  = new MaskedDateInputViewModel();
                HasNoPrenotification = true;
            }

            ShipmentNumber = data.Number;

            Comments     = data.Comments;
            StatsMarking = data.StatsMarking;

            if (!string.IsNullOrWhiteSpace(data.Comments) || !string.IsNullOrWhiteSpace(data.StatsMarking))
            {
                HasComments = true;
            }

            NotificationType     = data.NotificationType;
            IsReceived           = data.IsReceived;
            IsOperationCompleted = data.IsOperationCompleted;
            IsRejected           = data.IsRejected;
            IsPartiallyRejected  = data.IsPartiallyRejected;

            if (!data.IsReceived && !data.IsRejected && !data.IsPartiallyRejected)
            {
                data.IsReceived = true;
            }

            Receipt = new ReceiptViewModel
            {
                ActualQuantity   = data.ActualQuantity,
                ReceivedDate     = new MaskedDateInputViewModel(data.ReceiptDate),
                ActualUnits      = data.ReceiptUnits ?? data.NotificationUnits,
                ShipmentTypes    = data.IsReceived ? ShipmentType.Accepted : (data.IsRejected ? ShipmentType.Rejected : ShipmentType.Partially),
                RejectionReason  = data.RejectionReason,
                PossibleUnits    = data.PossibleUnits,
                RejectedQuantity = data.RejectedQuantity,
                RejectedUnits    = data.RejectedUnit
            };

            Recovery = new RecoveryViewModel
            {
                NotificationType = data.NotificationType,
                RecoveryDate     = new MaskedDateInputViewModel(data.OperationCompleteDate)
            };
        }
Beispiel #2
0
        public IndexViewModel(MovementReceiptAndRecoveryData data)
        {
            ActualShipmentDate = data.ActualDate;
            if (data.PrenotificationDate.HasValue)
            {
                PrenotificationDate = data.PrenotificationDate.Value;
            }
            else
            {
                HasNoPrenotification = true;
            }

            ShipmentNumber = data.Number;

            Comments     = data.Comments;
            StatsMarking = data.StatsMarking;

            if (!string.IsNullOrWhiteSpace(data.Comments) || !string.IsNullOrWhiteSpace(data.StatsMarking))
            {
                HasComments = true;
            }

            NotificationType     = data.NotificationType;
            IsRejected           = data.IsRejected;
            IsReceived           = data.IsReceived;
            IsOperationCompleted = data.IsOperationCompleted;
            ActualQuantity       = data.ActualQuantity;
            ReceivedDate         = data.ReceiptDate;
            Units = data.ReceiptUnits ?? data.NotificationUnits;
            WasShipmentAccepted = string.IsNullOrWhiteSpace(data.RejectionReason);
            RejectionReason     = data.RejectionReason;
            PossibleUnits       = data.PossibleUnits;
            NotificationType    = data.NotificationType;
            Date                = data.OperationCompleteDate;
            RejectedQuantity    = data.RejectedQuantity;
            RejectedUnits       = data.RejectedUnit;
            IsPartiallyRejected = data.IsPartiallyRejected;

            if (!data.IsReceived && !data.IsRejected && !data.IsPartiallyRejected)
            {
                IsReceived = true;
            }
        }
Beispiel #3
0
 public async Task SetMovementReceiptAndRecoveryData(MovementReceiptAndRecoveryData data, Guid createdBy)
 {
     await context.Database.ExecuteSqlCommandAsync(@"[Notification].[uspUpdateExportMovementData] 
         @NotificationId
         ,@MovementId
         ,@PrenotificationDate
         ,@HasNoPrenotification
         ,@ActualDate
         ,@ReceiptDate
         ,@Quantity
         ,@Unit
         ,@RejectiontDate
         ,@RejectionReason
         ,@StatsMarking
         ,@Comments
         ,@RecoveryDate
         ,@CreatedBy
         ,@RejectedQuantity
         ,@RejectedUnit",
                                                   new SqlParameter("@NotificationId", data.NotificationId),
                                                   new SqlParameter("@MovementId", data.Id),
                                                   new SqlParameter("@PrenotificationDate", (object)data.PrenotificationDate ?? DBNull.Value),
                                                   new SqlParameter("@HasNoPrenotification", (object)data.HasNoPrenotification ?? DBNull.Value),
                                                   new SqlParameter("@ActualDate", (object)data.ActualDate ?? DBNull.Value),
                                                   new SqlParameter("@ReceiptDate", (object)data.ReceiptDate ?? DBNull.Value),
                                                   new SqlParameter("@Quantity", data.ActualQuantity != null
             ? (object)decimal.Round(data.ActualQuantity.Value, data.ReceiptUnits != null
                 ? ShipmentQuantityUnitsMetadata.Precision[data.ReceiptUnits.Value]
                 : ShipmentQuantityUnitsMetadata.Precision.Values.Min())
             : DBNull.Value),
                                                   new SqlParameter("@Unit", (object)data.ReceiptUnits ?? DBNull.Value),
                                                   new SqlParameter("@RejectiontDate", (object)data.RejectionDate ?? DBNull.Value),
                                                   new SqlParameter("@RejectionReason", (object)data.RejectionReason ?? DBNull.Value),
                                                   new SqlParameter("@StatsMarking", (object)data.StatsMarking ?? DBNull.Value),
                                                   new SqlParameter("@Comments", (object)data.Comments ?? DBNull.Value),
                                                   new SqlParameter("@RecoveryDate", (object)data.OperationCompleteDate ?? DBNull.Value),
                                                   new SqlParameter("@CreatedBy", createdBy),
                                                   new SqlParameter("@RejectedQuantity", (object)data.RejectedQuantity ?? DBNull.Value),
                                                   new SqlParameter("@RejectedUnit", (object)data.RejectedUnit ?? DBNull.Value));
 }
        public async Task <ActionResult> Index(Guid id, Guid movementId, IndexViewModel model)
        {
            if (!ModelState.IsValid)
            {
                await UpdateSummary(model, id);

                return(View(model));
            }

            var data = new MovementReceiptAndRecoveryData
            {
                Id                    = movementId,
                NotificationId        = id,
                ActualDate            = model.ActualShipmentDate.Value,
                HasNoPrenotification  = model.PrenotificationDate.HasValue ? false : true,
                PrenotificationDate   = model.PrenotificationDate.HasValue ? model.PrenotificationDate.Value : (DateTime?)null,
                ReceiptDate           = (!model.IsRejected) && model.ReceivedDate.HasValue ? model.ReceivedDate.Value : (DateTime?)null,
                ActualQuantity        = model.ActualQuantity,
                ReceiptUnits          = model.Units,
                RejectionDate         = (model.IsRejected) && model.ReceivedDate.HasValue ? model.ReceivedDate.Value : (DateTime?)null,
                OperationCompleteDate = model.Date.HasValue ? model.Date.Value : (DateTime?)null,
                RejectionReason       = model.RejectionReason,
                Comments              = model.Comments,
                StatsMarking          = model.StatsMarking,
                RejectedQuantity      = model.RejectedQuantity,
                RejectedUnit          = model.RejectedUnits
            };

            await mediator.SendAsync(new SetMovementReceiptAndRecoveryData(data));

            await this.auditService.AddMovementAudit(this.mediator,
                                                     id, model.ShipmentNumber,
                                                     User.GetUserId(),
                                                     MovementAuditType.Edited);

            return(RedirectToAction("Edit", "CaptureMovement", new { movementId }));
        }
 public SetMovementReceiptAndRecoveryData(MovementReceiptAndRecoveryData data)
 {
     Data = data;
 }