public double GetTotalAsync(int cartId) { myHandler = new BusinessLogicHandler(); IEnumerable<Book> myBooks = myHandler.GetBooks(); IEnumerable<Technology> myGadget = myHandler.GetTechnology(); IEnumerable<CartItem> myItems; double final = 0; myItems = GetCartItemsAsync(cartId); if (myItems != null) { if (myBooks != null ) { var totalBook = from item in myItems join bi in myBooks on item.ProductID equals bi.ProductID where item.ProductID == bi.ProductID select (item.Quantity * bi.SellingPrice); final = (double)totalBook.Sum(); if (myGadget != null) { var total = from item in myItems join gadget in myGadget on item.ProductID equals gadget.ProductID where gadget.ProductID == item.ProductID select (item.Quantity * gadget.SellingPrice); final += (double)total.Sum(); } } return Math.Round(final, 2); } else return 0.00; }
public ActionResult AdminIndex(int? page) { myHandler = new BusinessLogicHandler(); List<Technology> myTechList = new List<Technology>(); myTechList = myHandler.GetTechnology(); IEnumerable<TechCategory> myType = myHandler.GetTechnologyTypeList(); ViewBag.TechTypeBag = myType; TempData["Alert Message"] = "Device Successfully Deleted"; return View(myTechList.ToList().ToPagedList(page ??1,20)); }
public ActionResult Index(int? page) { myHandler = new BusinessLogicHandler(); List<Technology> myGadgetList = myHandler.GetTechnology(); IEnumerable<Manufacturer> manufacturer = myHandler.GetManufacturers(); ViewBag.Manufact = manufacturer; return View(myGadgetList.ToList().ToPagedList(page ?? 1, 18)); }
public ActionResult Index() { #region Prep Utilities BusinessLogicHandler myHandler = new BusinessLogicHandler(); AdminIndexViewModel model = new AdminIndexViewModel(); model.BookSales = new List<CategorySalesPie>(); model.DeviceSales = new List<CategorySalesPie>(); #endregion #region Get Book Data IEnumerable<InvoiceItem> soldItems = myHandler.Sales(); IEnumerable<Book> books = myHandler.GetBooks(); IEnumerable<BookCategory> categories = myHandler.GetBookCategoryList(); #endregion #region Get Device Data IEnumerable<TechCategory> DeviceCategories = myHandler.GetTechnologyTypeList(); IEnumerable<Technology> Devices = myHandler.GetTechnology(); #endregion #region Build Book Data Set var dataSet = from soldT in soldItems join book in books on soldT.ProductID equals book.ProductID join category in categories on book.BookCategoryID equals category.BookCategoryID select new { soldT.Price, soldT.Quantity, category.CategoryName }; List<string> names = new List<string>(); foreach (var item in dataSet) { if (names.Contains(item.CategoryName)) { CategorySalesPie pie = new CategorySalesPie(); pie.Category = item.CategoryName; pie = model.BookSales.SingleOrDefault(m => m.Category == item.CategoryName); int x = model.BookSales.IndexOf(pie); if(x > -1) { model.BookSales[x].TotalSales += model.BookSales[x].TotalSales + (item.Price * item.Quantity); } } else { CategorySalesPie modelItem = new CategorySalesPie(); names.Add(item.CategoryName); modelItem.Category = item.CategoryName; modelItem.TotalSales = (item.Price * item.Quantity); model.BookSales.Add(modelItem); } } #region Trial System.Web.Script.Serialization.JavaScriptSerializer oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer(); #endregion //model.chartData = oSerializer.Serialize(model.BookSales.ToArray()); //model.chartData = JsonConvert.SerializeObject(model.BookSales.ToArray()); //model.chartData = JsonConvert.SerializeObject(model.oData); #endregion #region Build Device Data Set var DeviceDataSet = from soldT in soldItems join device in Devices on soldT.ProductID equals device.ProductID join category in DeviceCategories on device.TechCategoryID equals category.TechCategoryID select new { soldT.Price, soldT.Quantity, category.CategoryName }; List<string> namesList = new List<string>(); foreach (var item in DeviceDataSet) { if (namesList.Contains(item.CategoryName)) { CategorySalesPie pie = new CategorySalesPie(); pie.Category = item.CategoryName; pie = model.DeviceSales.SingleOrDefault(m => m.Category == item.CategoryName); int x = model.DeviceSales.IndexOf(pie); if (x > -1) { model.DeviceSales[x].TotalSales += model.DeviceSales[x].TotalSales + (item.Price * item.Quantity); } } else { CategorySalesPie modelItem = new CategorySalesPie(); namesList.Add(item.CategoryName); modelItem.Category = item.CategoryName; modelItem.TotalSales = (item.Price * item.Quantity); model.DeviceSales.Add(modelItem); } } #endregion return View(model); }