コード例 #1
0
        public ActionResult ListAllOrders()
        {
            CustomerOrderRepository cor            = new CustomerOrderRepository(ConstantUtil.MyConnectionString);
            List <CustomerOrder>    customerOrders = cor.GetAll();

            return(View(customerOrders));
        }
コード例 #2
0
        public String Delete(int id)
        {
            CustomerOrderRepository cor = new CustomerOrderRepository(ConstantUtil.MyConnectionString);

            cor.Delete(id);
            return("You successfully deleted the order with id: " + id);
        }
コード例 #3
0
        public ActionResult GetIndex(int id)
        {
            ViewBag.Customers = CustomerRepository.GetCustomerList();
            ViewBag.Products  = ProductRepository.GetProductList();

            var OrderViewDataModel = CustomerOrderRepository.GetOrder(id);

            List <OrderBox> BoxList = new List <OrderBox>();

            foreach (var item in OrderViewDataModel.CustomerOrder)
            {
                BoxList.Add(new OrderBox()
                {
                    Amount          = item.Amount,
                    Barcode         = item.Barcode,
                    Description     = item.Description,
                    GUID            = item.GUID,
                    Price           = Convert.ToDecimal(item.Price),
                    ProductId       = item.ProductId,
                    CustomerOrderId = item.CustomerOrderId,
                    ProductName     = item.ProductName
                });
            }
            Session["OrderBoxList"] = BoxList;

            return(View("Index", OrderViewDataModel));
        }
コード例 #4
0
        public void TestFindOrdersByCustomerFail()
        {
            var customerOrderRepository = new CustomerOrderRepository(null, mContext);
            var ordersByCustomer        = customerOrderRepository.FindOrdersByCustomerAsync(-1).Result;

            Assert.Empty(ordersByCustomer);
        }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
0
        public async Task <IDictionary <Guid, Customer> > ByOrders(string orderIds)
        {
            var manyToManyRepo = new CustomerOrderRepository();

            var _orderIds = orderIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
                            .Select(id => Guid.Parse(id))
                            .ToList();

            var allCustomers = await _repository.Customers();

            var allManyToMany = await manyToManyRepo.CustomerOrderRelationships();

            var data = allManyToMany
                       .Where(r => _orderIds.Contains(r.OrderId))
                       .Join(allCustomers, r => r.CustomerId, c => c.Id, (r, c) =>
            {
                return(new
                {
                    Customer = c,
                    OrderId = r.OrderId
                });
            })
                       .ToDictionary(a => a.OrderId, a => a.Customer);

            return(data);
        }
コード例 #8
0
#pragma warning disable IDE0060 // Remove unused parameter
        static void Main(string[] args)
        {
#pragma warning restore IDE0060 // Remove unused parameter

            ILoggerFactory MyLoggerFactory = LoggerFactory.Create(builder => { builder.AddConsole(); });

            string connectionString = ConnectionString.mConnectionString;

            DbContextOptions <Project0Context> options = new DbContextOptionsBuilder <Project0Context> ()
                                                         // .UseLoggerFactory (MyLoggerFactory)
                                                         .UseSqlServer(connectionString)
                                                         .Options;

            var handler = new IOHandler();

            var storeRepository    = new StoreRepository(options);
            var customerRepository = new CustomerRepository(options);
            var orderRepository    = new CustomerOrderRepository(options);
            var stockRepository    = new StoreStockRepository(options);

            // Let the customer input their name
            handler.AcceptCustomerName(customerRepository);

            // Let the customer choose which store to order from
            handler.AcceptStoreChoice(storeRepository, customerRepository);

            bool running = true;

            while (running)
            {
                // The customer can choose to see their orders,
                // see orders placed at the current store,
                // create a new order, or quit the application
                switch (handler.AcceptCustomerOption())
                {
                case IOHandler.Option.LIST_CUSTOMER_ORDERS:

                    handler.ListCustomerOrders(orderRepository);
                    break;

                case IOHandler.Option.LIST_STORE_ORDERS:

                    handler.ListStoreOrders(orderRepository);
                    break;

                case IOHandler.Option.NEW_ORDER:

                    handler.NewCustomerOrder(orderRepository, stockRepository);
                    break;

                case IOHandler.Option.QUIT:

                    running = false;
                    break;

                default:
                    break;
                }
            }
        }
コード例 #9
0
        //public String CheckOut(IEnumerable<ShoppingCartProduct> Model)
        //{
        //    CustomerRepository customerRepo = new CustomerRepository(ConstantUtil.MyConnectionString);
        //    Customer customer = customerRepo.GetById(1);
        //    CustomerOrder co = new CustomerOrder(1, 25);
        //    CustomerOrderRepository cor = new CustomerOrderRepository(ConstantUtil.MyConnectionString);
        //    int orderId = cor.Insert(co);

        //    List<CustomerOrderProduct> cops = new List<CustomerOrderProduct>();
        //    foreach (int scp in myModel.products)
        //    {
        //        CustomerOrderProduct temp = new CustomerOrderProduct(orderId, scp);
        //        ProductRepository pr = new ProductRepository(ConstantUtil.MyConnectionString);
        //        Product prod = pr.GetById(scp);
        //        temp.Quantity = 100;
        //        temp.UnitOfMeasure = prod.UnitOfMeasure;
        //        temp.UnitPrice = prod.UnitPrice;
        //        temp.CreatedBy = prod.CreatedBy;
        //        temp.CreatedDate = prod.CreatedDate;
        //        temp.LastModifiedBy = prod.LastModifiedBy;
        //        temp.LastModifiedDate = prod.LastModifiedDate;
        //        temp.Subtotal = 0;
        //        cops.Add(temp);
        //    }
        //    return "Successfully";
        //}

        public String CheckOut()
        {
            CustomerRepository      customerRepo = new CustomerRepository(ConstantUtil.MyConnectionString);
            Customer                customer     = customerRepo.GetById(1);
            CustomerOrder           co           = new CustomerOrder(1, 25);
            CustomerOrderRepository cor          = new CustomerOrderRepository(ConstantUtil.MyConnectionString);
            int orderId = cor.Insert(co);

            List <CustomerOrderProduct>       cops    = new List <CustomerOrderProduct>();
            ShoppingCartProductRepository     scpr    = new ShoppingCartProductRepository(ConstantUtil.MyConnectionString);
            IEnumerable <ShoppingCartProduct> myModel = scpr.GetAll();

            foreach (ShoppingCartProduct scp in myModel)
            {
                CustomerOrderProduct temp = new CustomerOrderProduct(orderId, scp.ProductId);
                //ProductRepository pr = new ProductRepository(ConstantUtil.MyConnectionString);
                //Product prod = pr.GetById(scp);
                temp.Quantity         = scp.Quantity;
                temp.UnitOfMeasure    = scp.UnitOfMeasure;
                temp.UnitPrice        = scp.UnitPrice;
                temp.CreatedBy        = scp.CreatedBy;
                temp.CreatedDate      = scp.CreatedDate;
                temp.LastModifiedBy   = scp.LastModifiedBy;
                temp.LastModifiedDate = scp.LastModifiedDate;
                temp.Subtotal         = scp.SubTotal;
                //cops.Add(temp);

                CustomerOrderProductRepository copr = new CustomerOrderProductRepository(ConstantUtil.MyConnectionString);
                copr.Insert(temp);
            }
            return("Successfully");
        }
コード例 #10
0
        public void TestFindOrdersByCustomer()
        {
            var customerOrderRepository = new CustomerOrderRepository(null, mContext);
            var ordersByCustomer        = customerOrderRepository.FindOrdersByCustomerAsync(1).Result;

            Assert.Single(ordersByCustomer);
            Assert.Equal(1, ordersByCustomer.First().CustomerId);
        }
コード例 #11
0
        public ActionResult GetByStatus(int statusId)
        {
            CustomerOrderRepository cor = new CustomerOrderRepository(ConstantUtil.MyConnectionString);

            statusId = ViewBag.Status;
            List <CustomerOrder> customerOrders = cor.GetCustomerOrderWithStatusId(statusId);

            return(View(customerOrders));
        }
コード例 #12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                var         status = cmbStatus.Text;
                OrderStatus orderStatus;
                //if ((status.ToUpper().Contains("OK") || status.ToUpper().Contains("REJECT")) )
                //{
                if (status.ToUpper().Contains("OK"))
                {
                    orderStatus = OrderStatus.Approved;
                }
                else if (status.ToUpper().Contains("REJECT"))
                {
                    orderStatus = OrderStatus.Rejected;
                }
                else if (status.ToUpper().Contains("SKIP"))
                {
                    orderStatus = OrderStatus.Skip;
                }
                else
                {
                    MessageBox.Show("Please select valid status");
                    return;
                }


                var saveStatus = new CustomerOrderRepository().ApproveRejectOrder(_orderID, orderStatus, txtReason.Text);
                if (saveStatus)
                {
                    MessageBox.Show("Status updated successfully.");
                    if (inspDashboard != null)
                    {
                        inspDashboard.LoadGridData();
                        new ScreensRepository().UpdateScreenReload(3, true);
                    }
                    if (dashboard != null)
                    {
                        dashboard.LoadGridData();
                    }
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Error while updating status, please contact administrator.");
                }

                //}
                //else {
                //    MessageBox.Show("Please select valid status");
                //}
            }
            catch (Exception ex) {
                LogException(ex);
            }
        }
コード例 #13
0
        /// <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);
        }
コード例 #14
0
        public ActionResult Get(Int32 id)
        {
            CustomerOrderRepository customerOrderRepository = new CustomerOrderRepository(ConstantUtil.AzureDb);

            CustomerOrder customerOrder = customerOrderRepository.GetById(id);

            if (customerOrder != null)
            {
                return(View(customerOrder));
            }

            return(View(customerOrder));
        }
コード例 #15
0
        public ActionResult Insert(CustomerOrder model)
        {
            CustomerOrderRepository customerOrderRepository = new CustomerOrderRepository(ConstantUtil.AzureDb);


            //String connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            //CategoryRepository categoryRepository = new CategoryRepository(connectionString);

            //if (customerOrderRepository.Insert(model))
            //    return View("Index", model);

            return(View("Index", model));
        }
コード例 #16
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);
        }
コード例 #17
0
        public HttpResponseMessage DeleteOrder(int id)
        {
            HttpResponseMessage message = null;

            try
            {
                CustomerOrderRepository customerRepo = new CustomerOrderRepository();
                customerRepo.DeleteOrder(id);

                message      = Request.CreateResponse(HttpStatusCode.Accepted, "Silme Başarılı");
                customerRepo = null;
            }
            catch (Exception ex)
            {
                message = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message.ToString());
            }

            return(message);
        }
コード例 #18
0
        public HttpResponseMessage GetOrder(int id)
        {
            HttpResponseMessage message = null;

            try
            {
                CustomerOrderRepository orderRepo = new CustomerOrderRepository();
                var order = orderRepo.GetOrder(id);

                message = Request.CreateResponse(HttpStatusCode.Accepted, order);
                order   = null;
            }
            catch (Exception ex)
            {
                message = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message.ToString());
            }

            return(message);
        }
コード例 #19
0
        public HttpResponseMessage GetAllOrders()
        {
            HttpResponseMessage message = null;

            try
            {
                CustomerOrderRepository customerRepo = new CustomerOrderRepository();
                var OrderList = customerRepo.GetAllOrders();

                message      = Request.CreateResponse(HttpStatusCode.Accepted, OrderList);
                customerRepo = null;
            }
            catch (Exception ex)
            {
                message = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message.ToString());
            }

            return(message);
        }
コード例 #20
0
        /// <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);
        }
コード例 #21
0
        public HttpResponseMessage PutOrder(int id, CustomerOrderHeaderDTO customerOrderHeaderDTO)
        {
            HttpResponseMessage message = null;

            try
            {
                CustomerOrderRepository customerRepo = new CustomerOrderRepository();
                customerRepo.PostOrder(customerOrderHeaderDTO);

                message = Request.CreateResponse(HttpStatusCode.Accepted, "Ekleme İşlem Tamamlandı");

                customerRepo = null;
            }
            catch (Exception ex)
            {
                message = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message.ToString());
            }

            return(message);
        }
コード例 #22
0
ファイル: Program.cs プロジェクト: Allytrice/TechTest
        public static void DisplayOrders()
        {
            List <Customer> customers     = new List <Customer>();
            CustomerOrder   customerOrder = new CustomerOrder();

            CustomerOrderRepository customerOrderRepository = new CustomerOrderRepository();

            customers = customerOrderRepository.LoadAllCustomers();

            foreach (var cust in customers)
            {
                customerOrder.orders = customerOrderRepository.LoadAllOrders(cust.CustomerId);
                Console.WriteLine("***************************************************");
                Console.WriteLine("Customer Name : " + cust.Name);
                Console.WriteLine("Orders: ");
                foreach (var order in customerOrder.orders)
                {
                    Console.WriteLine("\tOrder ID: " + order.OrderId);
                    Console.WriteLine("\tOrder Amount:" + order.Amount);
                }
            }
        }
コード例 #23
0
 public CustomerOrderService()
 {
     _repo = new CustomerOrderRepository();
 }
コード例 #24
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);
        }
コード例 #25
0
        /// <summary>
        /// convert customer order to view model
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public CustomerOrderViewModel ConvertToView(CustomerOrder order)
        {
            CustomerOrderViewModel model = new CustomerOrderViewModel();

            var _projectRepository                 = new ProjectRepository();
            var _customerDynamicsRepository        = new CustomerDynamicsRepository();
            var _customerAddressDynamicsRepository = new CustomerAddressDynamicsRepository();
            var _stateRepository           = new StateRepository();
            var _foundryDynamicsRepository = new FoundryDynamicsRepository();
            var _siteDynamicsRepository    = new SiteDynamicsRepository();
            var _orderTermRepository       = new OrderTermRepository();
            var _priceSheetRepository      = new PriceSheetRepository();
            var _customerOrderRepository   = new CustomerOrderRepository();

            var project            = _projectRepository.GetProject(order.ProjectId);
            var dynamicsCustomer   = _customerDynamicsRepository.GetCustomer(order.CustomerId);
            var dynamicsFoundry    = _foundryDynamicsRepository.GetFoundry(order.FoundryId);
            var dynamicsAddress    = _customerAddressDynamicsRepository.GetCustomerAddress(order.CustomerAddressId);
            var state              = _stateRepository.GetState((dynamicsAddress != null && !string.IsNullOrEmpty(dynamicsAddress.STATE)) ? dynamicsAddress.STATE : string.Empty);
            var stateName          = (state != null && !string.IsNullOrEmpty(state.Name)) ? ", " + state.Name : string.Empty;
            var dynamicsSite       = _siteDynamicsRepository.GetSite((dynamicsAddress != null && !string.IsNullOrEmpty(dynamicsAddress.LOCNCODE)) ? dynamicsAddress.LOCNCODE : string.Empty);
            var orderTerm          = _orderTermRepository.GetOrderTerm(order.ShipmentTermsId);
            var customerOrderParts = _customerOrderRepository.GetCustomerOrderParts().Where(x => x.CustomerOrderId == order.CustomerOrderId).ToList();

            model.CustomerOrderId       = order.CustomerOrderId;
            model.OrderDate             = order.PODate;
            model.PONumber              = (!string.IsNullOrEmpty(order.PONumber)) ? order.PONumber : "N/A";
            model.PODate                = order.PODate;
            model.PODateStr             = (order.PODate != null) ? order.PODate.ToShortDateString() : "N/A";
            model.ProjectId             = order.ProjectId;
            model.ProjectName           = (project != null && !string.IsNullOrEmpty(project.Name)) ? project.Name : "N/A";
            model.CustomerId            = order.CustomerId;
            model.CustomerName          = (dynamicsCustomer != null && !string.IsNullOrEmpty(dynamicsCustomer.SHRTNAME)) ? dynamicsCustomer.SHRTNAME : "N/A";
            model.CustomerAddressId     = order.CustomerAddressId;
            model.CustomerAddress       = (dynamicsAddress != null) ? dynamicsAddress.ADDRESS1 + " " + dynamicsAddress.CITY + stateName : "N/A";
            model.FoundryId             = order.FoundryId;
            model.FoundryName           = (dynamicsFoundry != null && !string.IsNullOrEmpty(dynamicsFoundry.VENDSHNM)) ? dynamicsFoundry.VENDSHNM : "N/A";
            model.SiteId                = order.SiteId;
            model.SiteDescription       = (dynamicsSite != null && !string.IsNullOrEmpty(dynamicsSite.LOCNDSCR)) ? dynamicsSite.LOCNDSCR : "N/A";
            model.ShipmentTermsId       = order.ShipmentTermsId;
            model.ShipmentTerms         = (orderTerm != null && !string.IsNullOrEmpty(orderTerm.Description)) ? orderTerm.Description : "N/A";
            model.PortDate              = (order.PortDate != null) ? order.PortDate : DateTime.MinValue;
            model.PortDateStr           = (order.PortDate != null) ? order.PortDate.Value.ToShortDateString() : "N/A";
            model.ShipDate              = (order.ShipDate != null) ? order.ShipDate : DateTime.MinValue;
            model.ShipDateStr           = (order.ShipDate != null) ? order.ShipDate.Value.ToShortDateString() : "N/A";
            model.DueDate               = (order.DueDate != null) ? order.DueDate : DateTime.MinValue;
            model.DueDateStr            = (order.DueDate != null) ? order.DueDate.Value.ToShortDateString() : "N/A";
            model.EstArrivalDate        = (order.EstArrivalDate != null) ? order.EstArrivalDate : DateTime.MinValue;
            model.EstArrivalDateStr     = (order.EstArrivalDate != null) ? order.EstArrivalDate.Value.ToShortDateString() : "N/A";
            model.OrderNotes            = (!string.IsNullOrEmpty(order.Notes)) ? order.Notes : "N/A";
            model.IsOpen                = order.IsOpen;
            model.IsHold                = order.IsHold;
            model.HoldExpirationDate    = (order.HoldExpirationDate != null) ? order.HoldExpirationDate : DateTime.MinValue;
            model.HoldExpirationDateStr = (order.HoldExpirationDate != null) ? order.HoldExpirationDate.Value.ToShortDateString() : "N/A";
            model.HoldNotes             = (!string.IsNullOrEmpty(order.HoldNotes)) ? order.HoldNotes : "N/A";
            model.IsCanceled            = order.IsCanceled;
            model.CanceledDate          = (order.CanceledDate != null) ? order.CanceledDate : DateTime.MinValue;
            model.CanceledDateStr       = (order.CanceledDate != null) ? order.CanceledDate.Value.ToShortDateString() : "N/A";
            model.CancelNotes           = (!string.IsNullOrEmpty(order.CancelNotes)) ? order.CancelNotes : "N/A";
            model.IsComplete            = order.IsComplete;
            model.CompletedDate         = (order.CompletedDate != null) ? order.CompletedDate : DateTime.MinValue;
            model.CompletedDateStr      = (order.CompletedDate != null) ? order.CompletedDate.Value.ToShortDateString() : "N/A";
            model.Status                = order.IsOpen ? "Open" : order.IsCanceled ? "Canceled" : order.IsComplete ? "Completed" : order.IsHold ? "On Hold" : "N/A";
            model.IsSample              = order.IsSample;
            model.IsTooling             = order.IsTooling;
            model.IsProduction          = order.IsProduction;
            model.OrderTypeDescription  = order.IsSample ? "Sample" : order.IsTooling ? "Tooling" : order.IsProduction ? "Production" : "N/A";

            model.CustomerOrderParts = new List <CustomerOrderPartViewModel>();

            var totalPrice = 0.00m;

            if (customerOrderParts != null && customerOrderParts.Count > 0)
            {
                foreach (var customerOrderPart in customerOrderParts)
                {
                    CustomerOrderPartViewModel partModel = new CustomerOrderPartViewModel();
                    if (model.OrderTypeDescription.Equals("Sample") || model.OrderTypeDescription.Equals("Tooling"))
                    {
                        partModel = new CustomerOrderPartConverter().ConvertToProjectPartView(customerOrderPart);
                    }
                    else
                    {
                        partModel = new CustomerOrderPartConverter().ConvertToPartView(customerOrderPart);
                    }
                    model.CustomerOrderParts.Add(partModel);
                    totalPrice += (partModel.Price * partModel.CustomerOrderQuantity);
                }
            }

            model.TotalPrice = Math.Round(totalPrice, 2);

            model.CustomerOrderParts = model.CustomerOrderParts.OrderByDescending(y => y.EstArrivalDate).ThenBy(y => y.PartNumber).ToList();

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

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

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

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

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

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

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

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

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

            return(model);
        }
コード例 #26
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);
        }
コード例 #27
0
        /// <summary>
        /// convert foundry order to view model
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public FoundryOrderViewModel ConvertToView(FoundryOrder order)
        {
            FoundryOrderViewModel model = new FoundryOrderViewModel();

            var _projectRepository                 = new ProjectRepository();
            var _customerDynamicsRepository        = new CustomerDynamicsRepository();
            var _customerAddressDynamicsRepository = new CustomerAddressDynamicsRepository();
            var _stateRepository           = new StateRepository();
            var _foundryDynamicsRepository = new FoundryDynamicsRepository();
            var _siteDynamicsRepository    = new SiteDynamicsRepository();
            var _orderTermRepository       = new OrderTermRepository();
            var _billOfLadingRepository    = new BillOfLadingRepository();
            var _customerOrderRepository   = new CustomerOrderRepository();
            var _foundryOrderRepository    = new FoundryOrderRepository();

            var project                 = _projectRepository.GetProject(order.ProjectId);
            var dynamicsCustomer        = _customerDynamicsRepository.GetCustomer(order.CustomerId);
            var dynamicsCustomerAddress = _customerAddressDynamicsRepository.GetCustomerAddress(order.CustomerAddressId);
            var state           = _stateRepository.GetState((dynamicsCustomerAddress != null && !string.IsNullOrEmpty(dynamicsCustomerAddress.STATE)) ? dynamicsCustomerAddress.STATE : string.Empty);
            var stateName       = (state != null && !string.IsNullOrEmpty(state.Name)) ? ", " + state.Name : string.Empty;
            var dynamicsFoundry = _foundryDynamicsRepository.GetFoundry(order.FoundryId);
            var dynamicsSite    = _siteDynamicsRepository.GetSite((dynamicsCustomerAddress != null && !string.IsNullOrEmpty(dynamicsCustomerAddress.LOCNCODE)) ? dynamicsCustomerAddress.LOCNCODE : string.Empty);
            var orderTerm       = _orderTermRepository.GetOrderTerm(order.ShipmentTermsId);
            var billOfLading    = _billOfLadingRepository.GetBillOfLadings().FirstOrDefault(x => x.FoundryId.Replace(" ", string.Empty).ToLower() == order.FoundryId.Replace(" ", string.Empty).ToLower());
            var parts           = _foundryOrderRepository.GetFoundryOrderParts().Where(x => x.FoundryOrderId == order.FoundryOrderId).ToList();

            model.FoundryOrderId        = order.FoundryOrderId;
            model.BillOfLadingId        = (billOfLading != null) ? billOfLading.BillOfLadingId : Guid.Empty;
            model.OrderNumber           = (!string.IsNullOrEmpty(order.Number)) ? order.Number : "N/A";
            model.CustomerId            = order.CustomerId;
            model.CustomerName          = (dynamicsCustomer != null && !string.IsNullOrEmpty(dynamicsCustomer.SHRTNAME)) ? dynamicsCustomer.SHRTNAME : "N/A";
            model.CustomerAddressId     = order.CustomerAddressId;
            model.CustomerAddress       = (dynamicsCustomerAddress != null) ? dynamicsCustomerAddress.ADDRESS1 + " " + dynamicsCustomerAddress.CITY + ", " + stateName : "N/A";
            model.ProjectId             = order.ProjectId;
            model.ProjectName           = (project != null) ? project.Name : "N/A";
            model.FoundryId             = order.FoundryId;
            model.FoundryName           = (dynamicsFoundry != null && !string.IsNullOrEmpty(dynamicsFoundry.VENDSHNM)) ? dynamicsFoundry.VENDSHNM : "N/A";
            model.OrderNotes            = (!string.IsNullOrEmpty(order.Notes)) ? order.Notes : "N/A";
            model.ShipmentTermsId       = order.ShipmentTermsId;
            model.ShipmentTerms         = (orderTerm != null) ? orderTerm.Description : "N/A";
            model.OrderDate             = order.OrderDate;
            model.PODate                = (order.OrderDate != null) ? order.OrderDate : DateTime.MinValue;
            model.PODateStr             = (order.OrderDate != null) ? order.OrderDate.ToShortDateString() : "N/A";
            model.DueDate               = (order.DueDate != null) ? order.DueDate : DateTime.MinValue;
            model.DueDateStr            = (order.DueDate != null) ? order.DueDate.Value.ToShortDateString() : "N/A";
            model.PortDate              = (order.PortDate != null) ? order.PortDate : DateTime.MinValue;
            model.PortDateStr           = (order.PortDate != null) ? order.PortDate.Value.ToShortDateString() : "N/A";
            model.ShipDate              = (order.ShipDate != null) ? order.ShipDate : DateTime.MinValue;
            model.ShipDateStr           = (order.ShipDate != null) ? order.ShipDate.Value.ToShortDateString() : "N/A";
            model.EstArrivalDate        = (order.EstArrivalDate != null) ? order.EstArrivalDate : DateTime.MinValue;
            model.EstArrivalDateStr     = (order.EstArrivalDate != null) ? order.EstArrivalDate.Value.ToShortDateString() : "N/A";
            model.ShipVia               = (!string.IsNullOrEmpty(order.ShipVia)) ? order.ShipVia : "N/A";
            model.TransitDays           = order.TransitDays;
            model.SiteId                = order.SiteId;
            model.SiteDescription       = (dynamicsSite != null && !string.IsNullOrEmpty(dynamicsSite.LOCNDSCR)) ? dynamicsSite.LOCNDSCR : "N/A";
            model.IsOpen                = order.IsOpen ? true : false;
            model.IsConfirmed           = order.IsConfirmed;
            model.ConfirmedDate         = (order.ConfirmedDate != null) ? order.ConfirmedDate : DateTime.MinValue;
            model.ConfirmedDateStr      = (order.ConfirmedDate != null) ? order.ConfirmedDate.Value.ToShortDateString() : "N/A";
            model.IsHold                = order.IsHold;
            model.HoldExpirationDate    = (order.HoldExpirationDate != null) ? order.HoldExpirationDate : DateTime.MinValue;
            model.HoldExpirationDateStr = (order.HoldExpirationDate != null) ? order.HoldExpirationDate.Value.ToShortDateString() : "N/A";
            model.HoldNotes             = (!string.IsNullOrEmpty(order.HoldNotes)) ? order.HoldNotes : "N/A";
            model.IsCanceled            = order.IsCanceled;
            model.CanceledDate          = (order.CanceledDate != null) ? order.CanceledDate : DateTime.MinValue;
            model.CanceledDateStr       = (order.CanceledDate != null) ? order.CanceledDate.Value.ToShortDateString() : "N/A";
            model.CancelNotes           = (!string.IsNullOrEmpty(order.CancelNotes)) ? order.CancelNotes : "N/A";
            model.IsComplete            = order.IsComplete;
            model.CompletedDate         = (order.CompletedDate != null) ? order.CompletedDate : DateTime.MinValue;
            model.CompletedDateStr      = (order.CompletedDate != null) ? order.CompletedDate.Value.ToShortDateString() : "N/A";
            model.Status                = order.IsOpen ? "Open" : order.IsCanceled ? "Canceled" : order.IsComplete ? "Completed" : order.IsHold ? "On Hold" : "N/A";
            model.IsSample              = order.IsSample;
            model.IsTooling             = order.IsTooling;
            model.IsProduction          = order.IsProduction;
            model.OrderTypeDescription  = order.IsSample ? "Sample" : order.IsTooling ? "Tooling" : order.IsProduction ? "Production" : "N/A";

            if (parts != null && parts.Count > 0)
            {
                var foundryOrderParts = new List <FoundryOrderPartViewModel>();

                var totalPrice = 0.00m;

                foreach (var part in parts)
                {
                    FoundryOrderPartViewModel foundryOrderPart = new FoundryOrderPartViewModel();

                    if (model.OrderTypeDescription.Equals("Sample") || model.OrderTypeDescription.Equals("Tooling"))
                    {
                        foundryOrderPart = new FoundryOrderPartConverter().ConvertToProjectPartView(part);
                    }
                    else
                    {
                        foundryOrderPart = new FoundryOrderPartConverter().ConvertToPartView(part);
                    }

                    foundryOrderParts.Add(foundryOrderPart);

                    totalPrice += (foundryOrderPart.Price * foundryOrderPart.FoundryOrderQuantity);
                }

                model.TotalPrice        = Math.Round(totalPrice, 2);
                model.FoundryOrderParts = foundryOrderParts;
            }

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

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

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

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

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

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

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

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

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

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

            return(model);
        }
コード例 #28
0
 public CustomerOrderBusiness(CustomerOrderRepository customerOrderRepository)
 {
     this._customerOrderRepository = customerOrderRepository;
 }