コード例 #1
0
ファイル: SalesService.cs プロジェクト: girishk55/hg
        private InvoiceDTO CreateInvoiceDTO(SalesOrderHeader salesOrder)
        {
            InvoiceDTO objInvoiceDTO = new InvoiceDTO();
            List <SalesOrderDetail> salesOrderDetails = _salesOrderDetailRepository.GetMany(x => x.SalesOrderID == salesOrder.SalesOrderID).ToList();
            List <ProductDTO>       lstProduct        = new List <ProductDTO>();

            foreach (SalesOrderDetail objSalesOrderDetail in salesOrderDetails)
            {
                Product    objProduct    = _productsRepository.GetById(objSalesOrderDetail.ProductID);
                ProductDTO objProductDTO = new ProductDTO();
                objProductDTO.Name      = objProduct.Name;
                objProductDTO.OrderQty  = objSalesOrderDetail.OrderQty;
                objProductDTO.LineTotal = objSalesOrderDetail.LineTotal;
                objProductDTO.UnitPrice = objSalesOrderDetail.UnitPrice;
                lstProduct.Add(objProductDTO);
            }

            objInvoiceDTO.CustomerID          = salesOrder.CustomerID;
            objInvoiceDTO.SalesOrderNumber    = salesOrder.SalesOrderNumber;
            objInvoiceDTO.PurchaseOrderNumber = salesOrder.PurchaseOrderNumber;
            objInvoiceDTO.Title      = salesOrder.Customer.Title;
            objInvoiceDTO.FirstName  = salesOrder.Customer.FirstName;
            objInvoiceDTO.MiddleName = salesOrder.Customer.MiddleName;
            objInvoiceDTO.LastName   = salesOrder.Customer.LastName;
            objInvoiceDTO.OrderDate  = salesOrder.OrderDate;
            objInvoiceDTO.DueDate    = salesOrder.DueDate;
            objInvoiceDTO.ShipDate   = salesOrder.ShipDate;
            objInvoiceDTO.SubTotal   = decimal.Round(salesOrder.SubTotal, 2, MidpointRounding.AwayFromZero);
            objInvoiceDTO.TaxAmt     = decimal.Round(salesOrder.TaxAmt, 2, MidpointRounding.AwayFromZero);
            objInvoiceDTO.Freight    = decimal.Round(salesOrder.Freight, 2, MidpointRounding.AwayFromZero);
            objInvoiceDTO.TotalDue   = decimal.Round(salesOrder.TotalDue, 2, MidpointRounding.AwayFromZero);
            List <CustomerAddress> lstCustomerAddress = _customerAddressRepository.GetMany(x => x.CustomerID == salesOrder.CustomerID).ToList();

            foreach (CustomerAddress customerAddress in lstCustomerAddress)
            {
                Address objAddress = _addressRepository.GetById(customerAddress.AddressID);

                if (customerAddress.AddressType.Equals("Shipping"))
                {
                    objInvoiceDTO.ShippingAddressLine1  = objAddress.AddressLine1;
                    objInvoiceDTO.ShippingAddressLine2  = objAddress.AddressLine2;
                    objInvoiceDTO.ShippingCity          = objAddress.City;
                    objInvoiceDTO.ShippingStateProvince = objAddress.StateProvince;
                    objInvoiceDTO.ShippingCountryRegion = objAddress.CountryRegion;
                    objInvoiceDTO.ShippingPostalCode    = objAddress.PostalCode;
                }
                else
                {
                    objInvoiceDTO.BillingAddressLine1  = objAddress.AddressLine1;
                    objInvoiceDTO.BillingAddressLine2  = objAddress.AddressLine2;
                    objInvoiceDTO.BillingCity          = objAddress.City;
                    objInvoiceDTO.BillingStateProvince = objAddress.StateProvince;
                    objInvoiceDTO.BillingCountryRegion = objAddress.CountryRegion;
                    objInvoiceDTO.BillingPostalCode    = objAddress.PostalCode;
                }
            }
            objInvoiceDTO.products = lstProduct;
            return(objInvoiceDTO);
        }
コード例 #2
0
        private InvoiceDTO CreateInvoiceDTO(SalesOrderHeader salesOrder)
        {
            InvoiceDTO objInvoiceDTO = new InvoiceDTO();
            List <SalesOrderDetail> salesOrderDetails = _salesOrderDetailRepository.GetMany(x => x.SalesOrderID == salesOrder.SalesOrderID).ToList();
            List <ProductDTO>       lstProduct        = new List <ProductDTO>();

            objInvoiceDTO.CustomerID          = salesOrder.CustomerID;
            objInvoiceDTO.SalesOrderNumber    = salesOrder.SalesOrderNumber;
            objInvoiceDTO.PurchaseOrderNumber = salesOrder.PurchaseOrderNumber;
            objInvoiceDTO.Title      = salesOrder.Customer.Title;
            objInvoiceDTO.FirstName  = salesOrder.Customer.FirstName;
            objInvoiceDTO.MiddleName = salesOrder.Customer.MiddleName;
            objInvoiceDTO.LastName   = salesOrder.Customer.LastName;
            objInvoiceDTO.OrderDate  = salesOrder.OrderDate;
            objInvoiceDTO.DueDate    = salesOrder.DueDate;
            objInvoiceDTO.ShipDate   = salesOrder.ShipDate;
            objInvoiceDTO.SubTotal   = decimal.Round(salesOrder.SubTotal, 2, MidpointRounding.AwayFromZero);
            objInvoiceDTO.TaxAmt     = decimal.Round(salesOrder.TaxAmt, 2, MidpointRounding.AwayFromZero);
            objInvoiceDTO.Freight    = decimal.Round(salesOrder.Freight, 2, MidpointRounding.AwayFromZero);
            objInvoiceDTO.TotalDue   = decimal.Round(salesOrder.TotalDue, 2, MidpointRounding.AwayFromZero);
            objInvoiceDTO.products   = lstProduct;
            return(objInvoiceDTO);
        }