public override List <IOrderBuilderResponse> BuildOrder() { try { List <IOrderBuilderResponse> Orders = new List <IOrderBuilderResponse>(); // fetching Order IDs DataSet OrdersID = new OrderDetailsDataLayer(UserProfileObj, OrderObj).FetchOrderDetailsByTypeAndStatus(); foreach (DataRow dr in OrdersID.Tables[0].Rows) { int OrderId = int.Parse(dr["oId"].ToString()); OrderObj.SetOrderID(OrderId); List <string> StoreLogoList = new List <string>(); OrderBuilderAbstract OrderBuilderObj = new OrderBuilder(UserProfileObj, OrderObj); StoreLogoList = OrderBuilderObj.BuildOrderStores(); DateTime OrderDate = OrderBuilderObj.BuildOrderDate(); int CurrentOrderId = OrderBuilderObj.BuildOrderId(); int ItemCount = OrderBuilderObj.BuildOrderItemCount(); double OrderAmount = OrderBuilderObj.BuildOrderAmount(); string Status = OrderBuilderObj.BuildOrderStatus(); BuilderResponseObj.SetStoreLogo(StoreLogoList); BuilderResponseObj.SetOrderDate(OrderDate); BuilderResponseObj.SetOrderID(CurrentOrderId); BuilderResponseObj.SetOrderItemCount(ItemCount); BuilderResponseObj.SetOrderAmount(OrderAmount); BuilderResponseObj.SetOrderStatus(Status); Orders.Add(BuilderResponseObj); } return(Orders); } catch (Exception ex) { Logger.Instance().Log(Fatal.Instance(), ex); throw ex; } }
public IOrderDetailsResponse FetchOrderDetailsByOrderID(IOrder OrderObj, IUserProfile UserProfileObj) { try { IOrderDetailsResponse Response = null; List <ITaxOrderDetailsByProduct> ProductList; DataSet OrderDetailsResponse = new OrderDetailsDataLayer(UserProfileObj, OrderObj).FetchOrderDetailsByID(); if (OrderDetailsResponse.Tables[0].Rows.Count > 0) { ProductList = new List <ITaxOrderDetailsByProduct>(); IOrderDetailsDateAndStatus OrderDetailsDateAndStatusObj = new OrderDetailsDateAndStatus(DateTime.Parse(OrderDetailsResponse.Tables[0].Rows[0]["date"].ToString()), OrderDetailsResponse.Tables[0].Rows[0]["statusName"].ToString()); foreach (DataRow dr in OrderDetailsResponse.Tables[2].Rows) { IStores StoreObj = new Stores(); StoreObj.SetStoreLogo(dr["storeLogo"].ToString()); IProduct ProductObj = new ProductsOnly(); ProductObj.SetProductName(dr["productName"].ToString()); ProductObj.SetProductImage(dr["productImage"].ToString()); ProductObj.SetProductQuantity(int.Parse(dr["quantity"].ToString())); ITaxOrderDetailsByProduct ProductListObj = new TaxOrderDetailsByProduct(StoreObj, ProductObj, double.Parse(dr["PreTaxProductPrice"].ToString()), double.Parse(dr["PostTaxProductPrice"].ToString()), double.Parse(dr["taxAmount"].ToString())); ProductList.Add(ProductListObj); } DataRow AddressRow = OrderDetailsResponse.Tables[1].Rows[0]; IAddress AddressObj = new Address( AddressRow["addressName"].ToString(), AddressRow["appt"].ToString(), AddressRow["postalCode"].ToString(), AddressRow["phone"].ToString(), AddressRow["city"].ToString(), AddressRow["city"].ToString(), AddressRow["Province"].ToString() ); DataRow TaxComputedRow = OrderDetailsResponse.Tables[3].Rows[0]; IComputedTaxPrice ComputedObj = new ComputedTaxPrice( int.Parse(TaxComputedRow["TotalUniqueQuantity"].ToString()), int.Parse(TaxComputedRow["TotalQuantity"].ToString()), double.Parse(TaxComputedRow["TotalPreTaxProductPrice"].ToString()), double.Parse(TaxComputedRow["TotalPostTaxProductPrice"].ToString()), double.Parse(TaxComputedRow["TotalTaxAmount"].ToString()) ); ICardDetails CardObj = new CardDetails(int.Parse(OrderDetailsResponse.Tables[0].Rows[0]["caID"].ToString())); ICardDetails OutputCardDecrypted = new CardDetailsBusinessLayerTemplate(UserProfileObj).Select(CardObj); Response = new OrderDetailResponse(true, ProductList, OrderDetailsDateAndStatusObj, AddressObj, ComputedObj, OutputCardDecrypted); } else { Response = new OrderDetailResponse(false); } return(Response); } catch (Exception ex) { Logger.Instance().Log(Warn.Instance(), ex); throw ex; } }
public override double BuildOrderAmount() { try { double OrderAmount = 0; OrderDetailsDataLayer OrderDetailsDataLayerObj = new OrderDetailsDataLayer(UserProfileObj, OrderObj); DataSet Output = OrderDetailsDataLayerObj.FetchOrderDetailsByType(); foreach (DataRow dr in Output.Tables[0].Rows) { if (int.Parse(dr["oId"].ToString()) == OrderObj.GetOrderID()) { OrderAmount = double.Parse(dr["Amount"].ToString()); } } return(OrderAmount); } catch (Exception ex) { Logger.Instance().Log(Fatal.Instance(), ex); throw ex; } }
public override DateTime BuildOrderDate() { try { string OrderDateTimeStr = null; OrderDetailsDataLayer OrderDetailsDataLayerObj = new OrderDetailsDataLayer(UserProfileObj, OrderObj); DataSet Output = OrderDetailsDataLayerObj.FetchOrderDetailsByType(); foreach (DataRow dr in Output.Tables[0].Rows) { if (int.Parse(dr["oId"].ToString()) == OrderObj.GetOrderID()) { OrderDateTimeStr = DateTime.Parse(dr["date"].ToString()).ToString(); } } return(DateTime.Parse(OrderDateTimeStr)); } catch (Exception ex) { Logger.Instance().Log(Fatal.Instance(), ex); throw ex; } }
public override string BuildOrderStatus() { try { string Status = null; OrderDetailsDataLayer OrderDetailsDataLayerObj = new OrderDetailsDataLayer(UserProfileObj, OrderObj); DataSet Output = OrderDetailsDataLayerObj.FetchOrderDetailsByType(); foreach (DataRow dr in Output.Tables[0].Rows) { if (int.Parse(dr["oId"].ToString()) == OrderObj.GetOrderID()) { Status = dr["statusName"].ToString(); } } return(Status); } catch (Exception ex) { Logger.Instance().Log(Fatal.Instance(), ex); throw ex; } }
public override List <String> BuildOrderStores() { try { List <string> StoreLogoList = new List <string>(); IOrderDetailsDataLayer OrderDetailsDataLayerObj = new OrderDetailsDataLayer(UserProfileObj, OrderObj); DataSet Output = OrderDetailsDataLayerObj.FetchOrderDetailsByType(); foreach (DataRow dr in Output.Tables[1].Rows) { if (int.Parse(dr["oId"].ToString()) == OrderObj.GetOrderID()) { IStores StoreImageObj = new Stores(); StoreImageObj.SetStoreLogo(dr["storeLogo"].ToString()); StoreLogoList.Add(StoreImageObj.GetStoreLogo()); } } return(StoreLogoList); } catch (Exception ex) { Logger.Instance().Log(Fatal.Instance(), ex); throw ex; } }