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); }
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); }
private static Employee GetEmployee(ProductivityImportModel productivityImportModel) { return(new Employee { Id = productivityImportModel.EmployeeId.Trim(), Name = productivityImportModel.EmployeeName }); }
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); }
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); }
private static Product GetProduct(ProductivityImportModel productivityImportModel) { var product = new Product { Id = productivityImportModel.ProductId ?? 0, Name = productivityImportModel.Product.Trim(), }; return(product); }
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); }
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); }