コード例 #1
0
 internal IResult <IntraWarehouseOrder> Update(DateTime timestamp, IIntraWarehouseOrderKey orderKey, IIntraWarehouseOrderParameters parameters)
 {
     if (orderKey == null)
     {
         throw new ArgumentNullException("orderKey");
     }
     return(GetUpdatedOrder(timestamp, orderKey, parameters));
 }
コード例 #2
0
        private IResult <IntraWarehouseOrder> GetUpdatedOrder(DateTime timestamp, IIntraWarehouseOrderKey orderKey, IIntraWarehouseOrderParameters parameters)
        {
            var employeeResult = new GetEmployeeCommand(UnitOfWork).GetEmployee(parameters);

            if (!employeeResult.Success)
            {
                return(employeeResult.ConvertTo <IntraWarehouseOrder>());
            }

            IntraWarehouseOrder order;

            if (orderKey != null)
            {
                var key = new IntraWarehouseOrderKey(orderKey);
                order = UnitOfWork.IntraWarehouseOrderRepository.FindByKey(key, o => o.PickedInventory.Items);
                if (order == null)
                {
                    return(new InvalidResult <IntraWarehouseOrder>(null, string.Format(UserMessages.IntraWarehouseOrderNotFound, key)));
                }
            }
            else
            {
                var pickedInventoryResult = new CreatePickedInventoryCommand(UnitOfWork).Execute(new CreatePickedInventoryCommandParameters
                {
                    EmployeeKey  = employeeResult.ResultingObject,
                    PickedReason = PickedReason.IntraWarehouseMovement,
                    TimeStamp    = timestamp
                });

                if (!pickedInventoryResult.Success)
                {
                    return(pickedInventoryResult.ConvertTo <IntraWarehouseOrder>());
                }

                var pickedInventory = pickedInventoryResult.ResultingObject;
                pickedInventory.Archived = true;

                order = UnitOfWork.IntraWarehouseOrderRepository.Add(new IntraWarehouseOrder
                {
                    DateCreated     = pickedInventory.DateCreated,
                    Sequence        = pickedInventory.Sequence,
                    PickedInventory = pickedInventoryResult.ResultingObject
                });
            }

            order.TimeStamp  = timestamp;
            order.EmployeeId = employeeResult.ResultingObject.EmployeeId;
            order.Employee   = employeeResult.ResultingObject;

            order.OperatorName = parameters.OperatorName;
            order.MovementDate = parameters.MovementDate;

            return(new SuccessResult <IntraWarehouseOrder>(order));
        }