Ejemplo n.º 1
0
 public ActionResult AdminIndex(int? page)
 {
     myHandler = new BusinessLogicHandler();
     List<Book> myBookList = new List<Book>();
     myBookList = myHandler.GetBooks();
     myBookList.OrderBy(m => m.DateAdded);
     IEnumerable<BookCategory> myType = myHandler.GetBookCategoryList();
     ViewBag.BookTypeBag = myType;
     return View(myBookList.ToList().ToPagedList(page ?? 1, 20));
 }
Ejemplo n.º 2
0
        public ActionResult Categories()
        {
            #region Init Categories

            BusinessLogicHandler myHandler = new BusinessLogicHandler();
            SearchViewModel model = new SearchViewModel();

            #endregion

            #region Get Categories From db

            model.BookCategoryResults = myHandler.GetBookCategoryList();

            #endregion

            return View(model);
        }
Ejemplo n.º 3
0
 public ActionResult Details(int id)
 {
     myHandler = new BusinessLogicHandler();
     typeOf = myHandler.GetBookCategoryList().Single(typ => typ.BookCategoryID == id);
     return View(typeOf);
 }
Ejemplo n.º 4
0
 public ActionResult Index()
 {
     myHandler = new BusinessLogicHandler();
     List<BookCategory> typeList = myHandler.GetBookCategoryList();
     return View(typeList);
 }
Ejemplo n.º 5
0
        public ActionResult Edit(int id)
        {
            myHandler = new BusinessLogicHandler();
            typeOf = new BookCategory();

            typeOf = myHandler.GetBookCategoryList().Single(tlist => tlist.BookCategoryID == id);

            return View(typeOf);
        }
Ejemplo n.º 6
0
        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);
        }