Ejemplo n.º 1
0
        public EmployeeActionBase GetDbModel(ProductivityImportModel productivityImportModel)
        {
            EmployeeActionBase action = null;

            if (productivityImportModel.ProductId == null)
            {
                if (productivityImportModel.ClientCargoQuantityt == null &&
                    productivityImportModel.CommonCargoQuantity == null &&
                    productivityImportModel.WeightPerEmployee == null &&
                    productivityImportModel.VolumePerEmployee == null)
                {
                    action = GetOtherAction(productivityImportModel);
                }
                else
                {
                    action = GetShipmentAction(productivityImportModel);
                }
            }
            else if (!string.IsNullOrWhiteSpace(productivityImportModel.SenderAddress) &&
                     string.IsNullOrWhiteSpace(productivityImportModel.ReceiverAddress))
            {
                action = GetInventoryAction(productivityImportModel);
            }
            else if (string.IsNullOrWhiteSpace(productivityImportModel.SenderAddress) &&
                     !string.IsNullOrWhiteSpace(productivityImportModel.ReceiverAddress))
            {
                action = GetReceptionAction(productivityImportModel);
            }
            else
            {
                action = GetDoubleAddressAction(productivityImportModel);
            }

            return(action);
        }
Ejemplo n.º 2
0
        private static DoubleAddressAction GetDoubleAddressAction(ProductivityImportModel productivityImportModel)
        {
            var doubleAction = new DoubleAddressAction {
                Id           = productivityImportModel.DocumentNumber.Trim(),
                DocumentName = productivityImportModel.DocumentName,

                StartTime = productivityImportModel.StartTime,
                Duration  = TimeSpan.FromSeconds(productivityImportModel.OperationDuration),
                Operation = new Operation {
                    Name = productivityImportModel.Operation.Trim()
                },
                Employee = GetEmployee(productivityImportModel),

                DoubleAddressDetails = new List <DoubleAddressActionDetail> {
                    new DoubleAddressActionDetail {
                        ProductId       = productivityImportModel.ProductId ?? 0,
                        Product         = GetProduct(productivityImportModel),
                        ProductQuantity = productivityImportModel.ProductQuantity ?? 0,
                        SenderAddress   = GetAddress(productivityImportModel.SenderAddress),
                        ReceiverAddress = GetAddress(productivityImportModel.ReceiverAddress)
                    }
                }
            };

            return(doubleAction);
        }
Ejemplo n.º 3
0
 private static Employee GetEmployee(ProductivityImportModel productivityImportModel)
 {
     return(new Employee {
         Id = productivityImportModel.EmployeeId.Trim(),
         Name = productivityImportModel.EmployeeName
     });
 }
Ejemplo n.º 4
0
        private static ReceptionAction GetReceptionAction(ProductivityImportModel productivityImportModel)
        {
            var reception = new ReceptionAction {
                Id           = productivityImportModel.DocumentNumber.Trim(),
                DocumentName = productivityImportModel.DocumentName,

                StartTime = productivityImportModel.StartTime,
                Duration  = TimeSpan.FromSeconds(productivityImportModel.OperationDuration),
                Operation = new Operation {
                    Name = productivityImportModel.Operation.Trim()
                },
                Employee = GetEmployee(productivityImportModel),

                ReceptionActionDetails = new List <ReceptionActionDetail> {
                    new ReceptionActionDetail {
                        ProductId        = productivityImportModel.ProductId ?? 0,
                        Product          = GetProduct(productivityImportModel),
                        Address          = GetAddress(productivityImportModel.ReceiverAddress),
                        ScanQuantity     = (short)(productivityImportModel.ScanQuantity ?? 0),
                        ProductQuantity  = productivityImportModel.ProductQuantity ?? 0,
                        IsClientScanning = productivityImportModel.IsClientScanning ?? false
                    }
                }
            };

            return(reception);
        }
Ejemplo n.º 5
0
        private static InventoryAction GetInventoryAction(ProductivityImportModel productivityImportModel)
        {
            var inventory = new InventoryAction {
                Id           = productivityImportModel.DocumentNumber.Trim(),
                DocumentName = productivityImportModel.DocumentName,

                StartTime = productivityImportModel.StartTime,
                Duration  = TimeSpan.FromSeconds(productivityImportModel.OperationDuration),
                Operation = new Operation {
                    Name = productivityImportModel.Operation.Trim()
                },
                Employee = GetEmployee(productivityImportModel),

                InventoryActionDetails = new List <InventoryActionDetail> {
                    new InventoryActionDetail {
                        ProductId          = productivityImportModel.ProductId ?? 0,
                        Product            = GetProduct(productivityImportModel),
                        ProductQuantity    = productivityImportModel.ProductQuantity ?? 0,
                        Address            = GetAddress(productivityImportModel.SenderAddress),
                        AccountingQuantity = productivityImportModel.AccountingQuantity ?? 0,
                    }
                }
            };

            return(inventory);
        }
Ejemplo n.º 6
0
        private static Product GetProduct(ProductivityImportModel productivityImportModel)
        {
            var product = new Product {
                Id   = productivityImportModel.ProductId ?? 0,
                Name = productivityImportModel.Product.Trim(),
            };

            return(product);
        }
Ejemplo n.º 7
0
        private static OtherAction GetOtherAction(ProductivityImportModel productivityImportModel)
        {
            var other = new OtherAction {
                Id           = productivityImportModel.DocumentNumber.Trim(),
                DocumentName = productivityImportModel.DocumentName,

                StartTime = productivityImportModel.StartTime,
                Duration  = TimeSpan.FromSeconds(productivityImportModel.OperationDuration),
                Operation = new Operation {
                    Name = productivityImportModel.Operation.Trim()
                },
                Employee = GetEmployee(productivityImportModel),
            };

            return(other);
        }
Ejemplo n.º 8
0
        private static ShipmentAction GetShipmentAction(ProductivityImportModel productivityImportModel)
        {
            var id       = productivityImportModel.DocumentNumber.Trim();
            var shipment = new ShipmentAction {
                Id           = id,
                DocumentName = productivityImportModel.DocumentName,

                StartTime = productivityImportModel.StartTime,
                Duration  = TimeSpan.FromSeconds(productivityImportModel.OperationDuration),
                Operation = new Operation {
                    Name = productivityImportModel.Operation.Trim()
                },
                EmployeeId = productivityImportModel.EmployeeId,
                Employee   = GetEmployee(productivityImportModel),

                Weight = ( float? )productivityImportModel.WeightPerEmployee,
                Volume = ( float? )productivityImportModel.VolumePerEmployee,
                ClientCargoQuantity = ( float? )productivityImportModel.ClientCargoQuantityt,
                CommonCargoQuantity = ( float? )productivityImportModel.CommonCargoQuantity
            };

            return(shipment);
        }