public ActionResult GetAllShopsByStatus(bool IsActive) { Dictionary <string, object> returnObject = new Dictionary <string, object>(); try { List <Models.Shop> shopsList = new List <Models.Shop>(); shopsList = _shopData.GetAllShopsByStaus(IsActive); if (shopsList != null) { returnObject.Add("ShopsList", shopsList); returnObject.Add("status", "success"); } else { returnObject.Add("status", "fail"); } } catch (Exception) { } return(Json(new { message = returnObject }, JsonRequestBehavior.AllowGet)); }
public ActionResult GetAllOrdersDates(string ShopId, string FilterDate) { Dictionary <string, object> returnObject = new Dictionary <string, object>(); try { List <Models.Order> OrderList = new List <Models.Order>(); OrderList = _orderUtility.GetAllOrdersDates(ShopId, FilterDate); if (OrderList != null) { if (!string.IsNullOrEmpty(ShopId)) { int awaitingOrdersCount = OrderList.Where(x => x.Status == "awaiting").ToList().Count; int inprogressOrdersCount = OrderList.Where(x => x.Status == "inprogress").ToList().Count; int completedOrdersCount = OrderList.Where(x => x.Status == "completed").ToList().Count; int droppedOrdersCount = OrderList.Where(x => x.Status == "dropped").ToList().Count; List <int> _totalAmount = OrderList.Select(x => x.Amount).ToList(); int TotalAmout = 0; if (_totalAmount != null && _totalAmount.Count > 0) { TotalAmout = _totalAmount.Take(_totalAmount.Count).Sum(); } List <int> _receivedAmount = OrderList.Where(x => x.Status == "completed").Select(x => x.Amount).ToList(); int ReceivedAmout = 0; if (_receivedAmount != null && _receivedAmount.Count > 0) { ReceivedAmout = _receivedAmount.Take(_receivedAmount.Count).Sum(); } returnObject.Add("awaitingOrdersCount", awaitingOrdersCount); returnObject.Add("inprogressOrdersCount", inprogressOrdersCount); returnObject.Add("completedOrdersCount", completedOrdersCount); returnObject.Add("droppedOrdersCount", droppedOrdersCount); returnObject.Add("TotalAmount", TotalAmout); returnObject.Add("ReceivedAmount", ReceivedAmout); returnObject.Add("BalanceAmount", TotalAmout - ReceivedAmout); } else { Utilities.Shop shopUtility = new Utilities.Shop(); var ShopsList = shopUtility.GetAllShopsByStaus(true); if (ShopsList != null && ShopsList.Count > 0) { List <Models.ShopInfoForChart> shopInfoForChartsList = new List <Models.ShopInfoForChart>(); foreach (var Shop in ShopsList) { var SingleShopOrderList = _orderUtility.GetAllOrdersDates(Shop.Id, FilterDate); int awaitingOrdersCount = SingleShopOrderList.Where(x => x.Status == "awaiting").ToList().Count; int inprogressOrdersCount = SingleShopOrderList.Where(x => x.Status == "inprogress").ToList().Count; int completedOrdersCount = SingleShopOrderList.Where(x => x.Status == "completed").ToList().Count; int droppedOrdersCount = SingleShopOrderList.Where(x => x.Status == "dropped").ToList().Count; List <int> _totalAmount = SingleShopOrderList.Select(x => x.Amount).ToList(); int TotalAmout = 0; if (_totalAmount != null && _totalAmount.Count > 0) { TotalAmout = _totalAmount.Take(_totalAmount.Count).Sum(); } List <int> _receivedAmount = SingleShopOrderList.Where(x => x.Status == "completed").Select(x => x.Amount).ToList(); int ReceivedAmout = 0; if (_receivedAmount != null && _receivedAmount.Count > 0) { ReceivedAmout = _receivedAmount.Take(_receivedAmount.Count).Sum(); } Models.ShopInfoForChart shopInfoForChart = new Models.ShopInfoForChart() { Id = Shop.Id, Name = Shop.Name, TotalOrdersCount = SingleShopOrderList.Count, AwaitingOrdersCount = awaitingOrdersCount, InprogressOrdersCount = inprogressOrdersCount, CompletedOrdersCount = completedOrdersCount, DroppedOrdersCount = droppedOrdersCount, TotalAmount = TotalAmout, ReceivedAmount = ReceivedAmout, BalanceAmount = TotalAmout - ReceivedAmout }; shopInfoForChartsList.Add(shopInfoForChart); } returnObject.Add("ShopInfoForChartsList", shopInfoForChartsList); } } returnObject.Add("OrderList", OrderList); returnObject.Add("status", "success"); } else { returnObject.Add("status", "fail"); } } catch (Exception exe) { } return(Json(new { message = returnObject }, JsonRequestBehavior.AllowGet)); }