public static void CopyFromEntity(AllOrderDetails response, Order order) { response.agentadmin_mobile = order.AgentAdmin != null ? order.AgentAdmin.MobileNumber : string.Empty; response.agentadmin_image = order.AgentAdmin != null ? ImagePathService.agentAdminImagePath + order.AgentAdmin.ProfileImage : string.Empty; response.agentadmin_name = order.AgentAdmin != null ? order.AgentAdmin.AgentAdminName : string.Empty; response.delivery_date = Common.ToDateFormat(order.DeliveryDate); response.delivery_status = order.OrderDeliveries.Count > 0 ? order.OrderDeliveries.Where(x => x.OrdrID == order.OrdrID).FirstOrDefault().StatusId : 0; response.grand_total = order.GrandTotal; response.invoice_number = order.InvoiceNumber; response.order_date = Common.ToDateFormat(order.OrderDate); response.order_id = order.OrdrID; response.order_status = order.StatusID; response.order_time = order.OrderTime.ToString(); response.time_slot_name = order.MDeliverySlot != null ? order.MDeliverySlot.SlotName : string.Empty; if (response.driver_details == null) { response.driver_details = new DriverDetailsDto(); } if (order.Driver != null) { response.driver_details.driver_id = order.Driver.DrvrID; response.driver_details.driver_name = order.Driver.DriverName; response.driver_details.driver_image = ImagePathService.driverImagePath + order.Driver.ProfileImage; response.driver_details.driver_mobile = order.Driver.MobileNumber; } else { response.driver_details.driver_name = string.Empty; response.driver_details.driver_image = string.Empty; response.driver_details.driver_mobile = string.Empty; } if (response.product_details == null) { response.product_details = new List <ProductsDto>(); } foreach (var item in order.OrderDetails) { ProductsDto prodDto = new ProductsDto(); OrdersHelper.CopyFromEntity(prodDto, item); response.product_details.Add(prodDto); } response.has_exchange = (order.OrderPrdocuctExchanges.Count > 0 ? 1 : 0); if (response.has_exchange == 1) { if (response.exchange == null) { response.exchange = new List <ExchangeDto>(); } foreach (var item in order.OrderPrdocuctExchanges) { ExchangeDto exDto = new ExchangeDto(); OrdersHelper.CopyFromEntity(exDto, item); response.exchange.Add(exDto); } } }
public static void CopyFromEntity(OrderInvoiceDto dto, Order order) { dto.order_id = order.OrdrID; dto.invoice_number = order.InvoiceNumber; dto.consumer_name = order.Consumer.Name; dto.consumer_mobile = order.Consumer.PhoneNumber; dto.consumer_address = order.ConsumerAddress.Address; dto.consumer_location = order.ConsumerAddress.RegionName; dto.order_date = Common.ToDateFormat(order.OrderDate); List <ProductsDto> pdtos = new List <ProductsDto>(); decimal sumPromoProduct = 0; decimal sumPromoShipping = 0; decimal sumPromoRefill = 0; decimal sumPromoExchange = 0; foreach (OrderDetail det in order.OrderDetails) { ProductsDto pdt = new ProductsDto(); pdt.product_id = det.Product.ProdID; pdt.product_name = det.Product.ProductName; pdt.product_promo = det.PromoProduct; pdt.quantity = det.Quantity; pdt.shipping_cost = det.ShippingCharge; pdt.shipping_promo = det.PromoShipping; pdt.sub_total = det.SubTotal; pdt.unit_price = det.UnitPrice; pdt.refill_price = det.RefillPrice; pdt.refill_promo = det.PromoRefill; pdt.refill_quantity = det.RefillQuantity; pdtos.Add(pdt); if (det.PromoProduct != Convert.ToDecimal(0)) { sumPromoShipping += det.PromoShipping; } if (det.RefillQuantity > 0) { sumPromoShipping += det.PromoShipping; } sumPromoProduct += det.PromoProduct; sumPromoRefill += det.PromoRefill; dto.has_exchange = (order.OrderPrdocuctExchanges.Count > 0 ? 1 : 0); if (dto.has_exchange == 1) { if (dto.exchange == null) { dto.exchange = new List <Pertamina.LPG.API.DTOs.Orders.ExchangeDto>(); } foreach (var item in order.OrderPrdocuctExchanges) { Pertamina.LPG.API.DTOs.Orders.ExchangeDto exDto = new Pertamina.LPG.API.DTOs.Orders.ExchangeDto(); OrdersHelper.CopyFromEntity(exDto, item); dto.exchange.Add(exDto); sumPromoExchange += exDto.exchange_promo_price; sumPromoShipping += det.PromoShipping; } } } dto.agency_id = order.AgentAdmin.Agency.AgenID; dto.agency_name = order.AgentAdmin.Agency.AgencyName; dto.agency_address = order.AgentAdmin.Agency.MRegion.RegionName; dto.agency_location = order.AgentAdmin.Agency.MRegion.RegionName; //dto.agency_address = order.AgentAdmin.Agency.Region; //dto.agency_location = order.AgentAdmin.Agency.Region; dto.grand_total = order.GrandTotal; dto.grand_discount = (Math.Abs(sumPromoProduct) + Math.Abs(sumPromoShipping) + Math.Abs(sumPromoRefill) + Math.Abs(sumPromoExchange)) * -1; dto.grand_total_with_discount = dto.grand_total + Math.Abs(dto.grand_discount); dto.products = pdtos.ToArray(); }
public static void CopyFromEntity(OrderFullDetailsDto dto, Order order, Driver drv = null) { dto.order_id = order.OrdrID; dto.delivery_date = Common.ToDateFormat(order.DeliveryDate); dto.delivery_time_slot = order.MDeliverySlot.SlotName; dto.invoice_number = order.InvoiceNumber; dto.order_status = order.StatusID; dto.order_date = Common.ToDateFormat(order.OrderDate); dto.consumer_name = order.Consumer.Name; dto.consumer_mobile = order.Consumer.PhoneNumber; dto.consumer_address = order.ConsumerAddress.Address; dto.consumer_location = order.ConsumerAddress.RegionName; dto.driver = new DriverDetailsDto(); if (order.OrderDeliveries.Count > 0) { OrderDelivery od = order.OrderDeliveries.First(); dto.driver = new DriverDetailsDto(); if (drv == null) { drv = od.Driver; } CopyFromEntity(dto.driver, drv); //dto.driver.driver_id = od.Driver.DrvrID; //dto.driver.driver_image = od.Driver.ProfileImage; //dto.driver.driver_mobile = od.Driver.MobileNumber; //dto.driver.driver_name = od.Driver.DriverName; ////dto.driver.driver_rating = od.Driver.ra } List <ProductsDto> pdtos = new List <ProductsDto>(); foreach (OrderDetail det in order.OrderDetails) { ProductsDto pdt = new ProductsDto(); pdt.product_id = det.Product.ProdID; pdt.product_name = det.Product.ProductName; pdt.product_promo = det.PromoProduct; pdt.quantity = det.Quantity; pdt.shipping_cost = det.ShippingCharge; pdt.shipping_promo = det.PromoShipping; pdt.sub_total = det.SubTotal; pdt.unit_price = det.UnitPrice; pdt.refill_price = det.RefillPrice; pdt.refill_promo = det.PromoRefill; pdt.refill_quantity = det.RefillQuantity; pdtos.Add(pdt); } dto.grand_total = order.GrandTotal; dto.products = pdtos.ToArray(); dto.has_exchange = (order.OrderPrdocuctExchanges.Count > 0 ? 1 : 0); if (dto.has_exchange == 1) { if (dto.exchange == null) { dto.exchange = new List <ExchangeDto>(); } foreach (var item in order.OrderPrdocuctExchanges) { ExchangeDto exDto = new ExchangeDto(); OrdersHelper.CopyFromEntity(exDto, item); dto.exchange.Add(exDto); } } }