/// <summary> /// convert foundry order part to project part view model /// </summary> /// <param name="foundryOrderPart"></param> /// <returns></returns> public FoundryOrderPartViewModel ConvertToProjectPartView(FoundryOrderPart foundryOrderPart) { FoundryOrderPartViewModel model = new FoundryOrderPartViewModel(); var _foundryOrderRepository = new FoundryOrderRepository(); var _customerOrderRepository = new CustomerOrderRepository(); var _projectPartRepository = new ProjectPartRepository(); var _dynamicsReceiptRepository = new ReceiptDynamicsRepository(); var customerOrderPart = _customerOrderRepository.GetCustomerOrderPart(foundryOrderPart.CustomerOrderPartId); var projectPart = _projectPartRepository.GetProjectPart(foundryOrderPart.ProjectPartId); var customerOrder = _customerOrderRepository.GetCustomerOrder((customerOrderPart != null) ? customerOrderPart.CustomerOrderId : Guid.Empty); model.FoundryOrderPartId = foundryOrderPart.FoundryOrderPartId; model.CustomerOrderPartId = foundryOrderPart.CustomerOrderPartId; model.FoundryOrderId = foundryOrderPart.FoundryOrderId; model.ProjectPartId = foundryOrderPart.ProjectPartId; model.CustomerOrderId = (customerOrderPart != null) ? customerOrderPart.CustomerOrderId : Guid.Empty; model.AvailableQuantity = (customerOrderPart != null) ? customerOrderPart.AvailableQuantity : 0; model.FoundryOrderQuantity = foundryOrderPart.Quantity; model.PartNumber = (projectPart != null && !string.IsNullOrEmpty(projectPart.Number)) ? projectPart.Number : "N/A"; model.PartDescription = (projectPart != null && !string.IsNullOrEmpty(projectPart.Description)) ? projectPart.Description : "N/A"; model.PONumber = (customerOrder != null && !string.IsNullOrEmpty(customerOrder.PONumber)) ? customerOrder.PONumber : "N/A"; model.ShipCode = (!string.IsNullOrEmpty(foundryOrderPart.ShipCode)) ? foundryOrderPart.ShipCode : "N/A"; model.ShipCodeNotes = (!string.IsNullOrEmpty(foundryOrderPart.ShipCodeNotes)) ? foundryOrderPart.ShipCodeNotes : "N/A"; model.EstArrivalDate = (foundryOrderPart.EstArrivalDate != null) ? foundryOrderPart.EstArrivalDate : DateTime.MinValue; model.EstArrivalDateStr = (foundryOrderPart.EstArrivalDate != null) ? foundryOrderPart.EstArrivalDate.Value.ToShortDateString() : "N/A"; model.ShipDate = (foundryOrderPart.ShipDate != null) ? foundryOrderPart.ShipDate : DateTime.MinValue; model.ShipDateStr = (foundryOrderPart.ShipDate != null) ? foundryOrderPart.ShipDate.Value.ToShortDateString() : "N/A"; model.Cost = foundryOrderPart.Cost; model.Price = foundryOrderPart.Price; model.IsScheduled = foundryOrderPart.IsScheduled; model.HasBeenReceived = foundryOrderPart.HasBeenReceived; model.ReceiptDate = (foundryOrderPart.ReceiptDate != null) ? foundryOrderPart.ReceiptDate : DateTime.MinValue; model.ReceiptDateStr = (foundryOrderPart.ReceiptDate != null) ? foundryOrderPart.ReceiptDate.Value.ToShortDateString() : "N/A"; model.ReceiptQuantity = foundryOrderPart.ReceiptQuantity; if (_foundryOrderRepository != null) { _foundryOrderRepository.Dispose(); _foundryOrderRepository = null; } if (_customerOrderRepository != null) { _customerOrderRepository.Dispose(); _customerOrderRepository = null; } if (_projectPartRepository != null) { _projectPartRepository.Dispose(); _projectPartRepository = null; } if (_dynamicsReceiptRepository != null) { _dynamicsReceiptRepository.Dispose(); _dynamicsReceiptRepository = null; } return(model); }
/// <summary> /// convert customer order part to project part view model /// </summary> /// <param name="customerOrderPart"></param> /// <returns></returns> public CustomerOrderPartViewModel ConvertToProjectPartView(CustomerOrderPart customerOrderPart) { CustomerOrderPartViewModel model = new CustomerOrderPartViewModel(); var _priceSheetRepository = new PriceSheetRepository(); var _projectPartRepository = new ProjectPartRepository(); var _customerOrderRepository = new CustomerOrderRepository(); var _foundryOrderRepository = new FoundryOrderRepository(); var priceSheetPart = _priceSheetRepository.GetPriceSheetPart(customerOrderPart.PriceSheetPartId); var projectPart = _projectPartRepository.GetProjectPart((customerOrderPart.ProjectPartId != null) ? customerOrderPart.ProjectPartId : Guid.Empty); var priceSheet = _priceSheetRepository.GetPriceSheet((priceSheetPart != null) ? priceSheetPart.PriceSheetId : Guid.Empty); var customerOrder = _customerOrderRepository.GetCustomerOrder(customerOrderPart.CustomerOrderId); var receivedQuantity = _foundryOrderRepository.GetFoundryOrderParts().Where(x => x.CustomerOrderPartId == customerOrderPart.CustomerOrderPartId && x.HasBeenReceived).Select(y => y.ReceiptQuantity).Sum(); model.CustomerOrderPartId = customerOrderPart.CustomerOrderPartId; model.CustomerOrderId = customerOrderPart.CustomerOrderId; model.PONumber = (!string.IsNullOrEmpty(customerOrder.PONumber)) ? customerOrder.PONumber : "N/A"; model.ProjectPartId = customerOrderPart.ProjectPartId; model.PriceSheetPartId = customerOrderPart.PriceSheetPartId; model.PriceSheetId = (priceSheet != null) ? priceSheet.PriceSheetId : Guid.Empty; model.AvailableQuantity = customerOrderPart.AvailableQuantity; model.CustomerOrderQuantity = customerOrderPart.Quantity; model.PartNumber = (projectPart != null && !string.IsNullOrEmpty(projectPart.Number)) ? projectPart.Number : "N/A"; model.PartDescription = (projectPart != null && !string.IsNullOrEmpty(projectPart.Description)) ? projectPart.Description : "N/A"; model.PriceSheetNumber = (priceSheet != null && !string.IsNullOrEmpty(priceSheet.Number)) ? priceSheet.Number : "N/A"; model.EstArrivalDate = (customerOrderPart.EstArrivalDate != null) ? customerOrderPart.EstArrivalDate : DateTime.MinValue; model.EstArrivalDateStr = (customerOrderPart.EstArrivalDate != null) ? customerOrderPart.EstArrivalDate.Value.ToShortDateString() : "N/A"; model.ReceiptQuantity = receivedQuantity; model.Cost = customerOrderPart.Cost; model.Price = customerOrderPart.Price; if (_priceSheetRepository != null) { _priceSheetRepository.Dispose(); _priceSheetRepository = null; } if (_projectPartRepository != null) { _projectPartRepository.Dispose(); _projectPartRepository = null; } if (_customerOrderRepository != null) { _customerOrderRepository.Dispose(); _customerOrderRepository = null; } return(model); }
/// <summary> /// convert container part to packlingList part view model /// </summary> /// <param name="containerPart"></param> /// <returns></returns> public PackingListPartViewModel ConvertToView(ContainerPart containerPart) { PackingListPartViewModel model = new PackingListPartViewModel(); var _foundryOrderRepository = new FoundryOrderRepository(); var _partRepository = new PartRepository(); var _dynamicsPartRepository = new PartDynamicsRepository(); var _customerOrderRepository = new CustomerOrderRepository(); var foundryOrderPart = _foundryOrderRepository.GetFoundryOrderPart(containerPart.FoundryOrderPartId); var part = _partRepository.GetPart(foundryOrderPart.PartId); var dynamicsPart = _dynamicsPartRepository.GetPartMaster((part != null) ? part.Number : null); var customerOrderPart = _customerOrderRepository.GetCustomerOrderPart(foundryOrderPart.CustomerOrderPartId); var customerOrder = _customerOrderRepository.GetCustomerOrder(customerOrderPart.CustomerOrderId); model.ShipCode = foundryOrderPart.ShipCode; model.PartNumber = (part != null && !string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A"; model.PartWeight = (dynamicsPart != null) ? (dynamicsPart.ITEMSHWT / 100.00m) : 0.00m; model.PartQuantity = containerPart.Quantity; model.PalletNumber = (!string.IsNullOrEmpty(containerPart.PalletNumber)) ? containerPart.PalletNumber : "N/A"; model.PONumber = (customerOrder != null && !string.IsNullOrEmpty(customerOrder.PONumber)) ? customerOrder.PONumber : "N/A"; model.PalletQuantity = containerPart.Quantity; model.InvoiceNumber = "Will fill in later"; if (_foundryOrderRepository != null) { _foundryOrderRepository.Dispose(); _foundryOrderRepository = null; } if (_partRepository != null) { _partRepository.Dispose(); _partRepository = null; } if (_dynamicsPartRepository != null) { _dynamicsPartRepository.Dispose(); _dynamicsPartRepository = null; } if (_customerOrderRepository != null) { _customerOrderRepository.Dispose(); _customerOrderRepository = null; } return(model); }
/// <summary> /// convert packlingList part to view model /// </summary> /// <param name="packingListPart"></param> /// <returns></returns> public PackingListPartViewModel ConvertToView(PackingListPart packingListPart) { PackingListPartViewModel model = new PackingListPartViewModel(); var _partRepository = new PartRepository(); var _customerOrderRepository = new CustomerOrderRepository(); var _dynamicsPartRepository = new PartDynamicsRepository(); var part = _partRepository.GetPart(packingListPart.PartNumber); var dynamicsPart = _dynamicsPartRepository.GetPartMaster((part != null) ? part.Number : null); var customerOrder = _customerOrderRepository.GetCustomerOrder(packingListPart.PONumber); model.PackingListPartId = packingListPart.PackingListPartId; model.PackingListId = packingListPart.PackingListId; model.PartId = (part != null) ? part.PartId : Guid.Empty; model.ShipCode = (!string.IsNullOrEmpty(packingListPart.ShipCode)) ? packingListPart.ShipCode : "N/A"; model.PartNumber = (!string.IsNullOrEmpty(packingListPart.PartNumber)) ? packingListPart.PartNumber : "N/A"; model.PartWeight = (dynamicsPart != null) ? (dynamicsPart.ITEMSHWT / 100.00m) : 0.00m; model.PartQuantity = packingListPart.PalletQuantity; model.PalletNumber = (!string.IsNullOrEmpty(packingListPart.PalletNumber)) ? packingListPart.PalletNumber : "N/A"; model.PalletQuantity = packingListPart.PalletQuantity; model.PalletWeight = packingListPart.PalletWeight; model.PalletTotal = packingListPart.PalletTotal; model.TotalPalletQuantity = packingListPart.TotalPalletQuantity; model.PONumber = (!string.IsNullOrEmpty(packingListPart.PONumber)) ? packingListPart.PONumber : "N/A"; model.CustomerOrderId = (customerOrder != null) ? customerOrder.CustomerOrderId : Guid.Empty; model.InvoiceNumber = (!string.IsNullOrEmpty(packingListPart.InvoiceNumber)) ? packingListPart.InvoiceNumber : "N/A"; if (_partRepository != null) { _partRepository.Dispose(); _partRepository = null; } if (_customerOrderRepository != null) { _customerOrderRepository.Dispose(); _customerOrderRepository = null; } return(model); }