Пример #1
0
        /// <summary>
        /// convert foundry order part view model to domain
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public FoundryOrderPart ConvertToDomain(FoundryOrderPartViewModel model)
        {
            FoundryOrderPart part = new FoundryOrderPart();

            var _customerOrderRepository = new CustomerOrderRepository();

            var customerOrderPart = _customerOrderRepository.GetCustomerOrderPart(model.CustomerOrderPartId);

            part.FoundryOrderPartId  = model.FoundryOrderPartId;
            part.ProjectPartId       = (customerOrderPart != null) ? customerOrderPart.ProjectPartId : null;
            part.PartId              = (customerOrderPart != null) ? customerOrderPart.PartId : null;
            part.CustomerOrderPartId = model.CustomerOrderPartId;
            part.AvailableQuantity   = model.AvailableQuantity;
            part.Quantity            = model.Quantity;
            part.EstArrivalDate      = model.EstArrivalDate;
            part.ShipDate            = model.ShipDate;
            part.ShipCode            = model.ShipCode;
            part.ShipCodeNotes       = model.ShipCodeNotes;
            part.Price           = model.Price;
            part.Cost            = model.Cost;
            part.IsScheduled     = model.IsScheduled;
            part.HasBeenReceived = model.HasBeenReceived;
            part.ReceiptDate     = model.ReceiptDate;
            part.ReceiptQuantity = model.ReceiptQuantity;

            if (_customerOrderRepository != null)
            {
                _customerOrderRepository.Dispose();
                _customerOrderRepository = null;
            }

            return(part);
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
        /// <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);
        }
Пример #4
0
        /// <summary>
        /// convert foundry order view model to domain
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public FoundryOrder ConvertToDomain(FoundryOrderViewModel model)
        {
            var _customerOrderRepository = new CustomerOrderRepository();

            FoundryOrder order = new FoundryOrder();


            order.FoundryOrderId     = model.FoundryOrderId;
            order.Number             = model.OrderNumber;
            order.CustomerId         = model.CustomerId;
            order.ProjectId          = model.ProjectId;
            order.CustomerAddressId  = model.CustomerAddressId;
            order.FoundryId          = model.FoundryId;
            order.SiteId             = model.SiteId;
            order.ShipmentTermsId    = model.ShipmentTermsId;
            order.OrderDate          = model.OrderDate ?? DateTime.Now;
            order.ShipDate           = model.ShipDate;
            order.EstArrivalDate     = model.EstArrivalDate;
            order.DueDate            = model.DueDate;
            order.PortDate           = model.PortDate;
            order.Notes              = model.OrderNotes;
            order.ShipVia            = model.ShipVia;
            order.TransitDays        = model.TransitDays;
            order.IsConfirmed        = model.IsConfirmed;
            order.ConfirmedDate      = model.ConfirmedDate;
            order.IsOpen             = model.IsOpen;
            order.IsHold             = model.IsHold;
            order.HoldExpirationDate = (model.IsHold) ? model.HoldExpirationDate : null;
            order.HoldNotes          = (model.IsHold) ? model.HoldNotes : null;
            order.IsCanceled         = model.IsCanceled;
            order.CanceledDate       = (model.IsCanceled) ? model.CanceledDate : null;
            order.CancelNotes        = (model.IsCanceled) ? model.CancelNotes : null;
            order.IsComplete         = model.IsComplete;
            order.CompletedDate      = model.CompletedDate;
            order.IsSample           = model.IsSample;
            order.IsTooling          = model.IsTooling;
            order.IsProduction       = model.IsProduction;

            if (model.FoundryOrderParts != null && model.FoundryOrderParts.Count > 0)
            {
                var foundryOrderParts = new List <FoundryOrderPart>();

                foreach (var foundryOrderPart in model.FoundryOrderParts)
                {
                    var customerOrderPart = _customerOrderRepository.GetCustomerOrderPart(foundryOrderPart.CustomerOrderPartId);

                    if (model.IsSample || model.IsTooling)
                    {
                        foundryOrderPart.ProjectPartId = (customerOrderPart != null) ? customerOrderPart.ProjectPartId : null;
                        foundryOrderPart.PartId        = null;
                    }
                    else
                    {
                        foundryOrderPart.ProjectPartId = null;
                        foundryOrderPart.PartId        = (customerOrderPart != null) ? customerOrderPart.PartId : null;
                    }

                    foundryOrderPart.FoundryOrderId = model.FoundryOrderId;

                    FoundryOrderPart orderPart = new FoundryOrderPartConverter().ConvertToDomain(foundryOrderPart);

                    foundryOrderParts.Add(orderPart);
                }

                order.FoundryOrderParts = foundryOrderParts;
            }

            if (_customerOrderRepository != null)
            {
                _customerOrderRepository.Dispose();
                _customerOrderRepository = null;
            }

            return(order);
        }
Пример #5
0
        /// <summary>
        /// convert container part to warehouse inventory list model
        /// </summary>
        /// <param name="containerPart"></param>
        /// <returns></returns>
        public WarehouseInventoryViewModel ConvertToListView(ContainerPart containerPart)
        {
            WarehouseInventoryViewModel model = new WarehouseInventoryViewModel();

            var _foundryOrderRepository  = new FoundryOrderRepository();
            var _customerOrderRepository = new CustomerOrderRepository();
            var _partRepository          = new PartRepository();
            var _dynamicsPartRepository  = new PartDynamicsRepository();
            var _containerRepository     = new ContainerRepository();

            var foundryOrderPart  = _foundryOrderRepository.GetFoundryOrderPart(containerPart.FoundryOrderPartId);
            var customerOrderPart = _customerOrderRepository.GetCustomerOrderPart((foundryOrderPart != null) ? foundryOrderPart.CustomerOrderPartId : Guid.Empty);
            var part         = _partRepository.GetPart((foundryOrderPart != null) ? foundryOrderPart.PartId : Guid.Empty);
            var dynamicsPart = _dynamicsPartRepository.GetPartMaster((part != null) ? part.Number : string.Empty);
            var container    = _containerRepository.GetContainer(containerPart.ContainerId);

            model.CustomerId       = (part != null) ? part.CustomerId : "N/A";
            model.ShipCode         = (foundryOrderPart != null) ? foundryOrderPart.ShipCode : "N/A";
            model.PartNumber       = (part != null && !string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A";
            model.PartWeight       = (dynamicsPart != null) ? (dynamicsPart.ITEMSHWT / 100.00m) : 0.00m;
            model.PalletNumber     = (!string.IsNullOrEmpty(part.Number)) ? containerPart.PalletNumber : "N/A";
            model.PalletQuantity   = containerPart.Quantity;
            model.TotalQuantity    = containerPart.Quantity;
            model.ContainerNumber  = (!string.IsNullOrEmpty(part.Number)) ? container.Number : "N/A";
            model.PONumber         = (customerOrderPart != null && !string.IsNullOrEmpty(customerOrderPart.CustomerOrder.PONumber)) ? customerOrderPart.CustomerOrder.PONumber : "N/A";
            model.WarehouseDate    = (foundryOrderPart != null) ? foundryOrderPart.ReceiptDate : DateTime.MinValue;
            model.WarehouseDateStr = (foundryOrderPart != null && foundryOrderPart.ReceiptDate != null) ? foundryOrderPart.ReceiptDate.Value.ToShortDateString() : "N/A";
            model.SixtyDaysDate    = (foundryOrderPart != null && foundryOrderPart.ReceiptDate != null) ? foundryOrderPart.ReceiptDate.Value.AddDays(60) : DateTime.MinValue;
            model.SixtyDaysDateStr = (model.SixtyDaysDate != null) ? model.SixtyDaysDate.Value.ToShortDateString() : "N/A";

            if (_foundryOrderRepository != null)
            {
                _foundryOrderRepository.Dispose();
                _foundryOrderRepository = null;
            }

            if (_customerOrderRepository != null)
            {
                _customerOrderRepository.Dispose();
                _customerOrderRepository = null;
            }

            if (_partRepository != null)
            {
                _partRepository.Dispose();
                _partRepository = null;
            }

            if (_dynamicsPartRepository != null)
            {
                _dynamicsPartRepository.Dispose();
                _dynamicsPartRepository = null;
            }

            if (_containerRepository != null)
            {
                _containerRepository.Dispose();
                _containerRepository = null;
            }

            return(model);
        }