public async Task <IActionResult> Index()
        {
            ViewBag.Loggedin   = HttpContext.Session.GetInt32("authenticated").HasValue;
            ViewBag.Categories = await categoryModel.GetAll();

            return(View());
        }
        public async Task <IActionResult> Index()
        {
            ViewBag.Loggedin   = HttpContext.Session.GetInt32("authenticated").HasValue;
            this.cartHelpers   = new Helpers.CartHelpers(this.HttpContext.Session);
            ViewBag.Categories = await categoryModel.GetAll();

            var cart = cartHelpers.GetCart();

            return(View(cart));
        }
Example #3
0
        public async Task <IActionResult> Index()
        {
            if (!HttpContext.Session.GetInt32("authenticated").HasValue)
            {
                return(new RedirectToActionResult("index", "login", null));
            }
            ViewBag.Loggedin   = HttpContext.Session.GetInt32("authenticated").HasValue;
            ViewBag.Categories = await categoryModel.GetAll();

            return(View());
        }
 public IActionResult Index(CategoryViewModel vm)
 {
     // only build the catalogue once
     if (HttpContext.Session.Get <List <Category> >("categories") == null)
     {
         // no session information so let's go to the database
         try
         {
             CategoryModel catModel = new CategoryModel(_db);
             // now load the categories
             List <Category> categories = catModel.GetAll();
             HttpContext.Session.Set <List <Category> >("categories", categories);
             vm.SetCategories(categories);
         }
         catch (Exception ex)
         {
             ViewBag.Message = "Catalogue Problem - " + ex.Message;
         }
     }
     else
     {
         // no need to go back to the database as information is already in the session
         vm.SetCategories(HttpContext.Session.Get <List <Category> >("categories"));
         MenuItemModel itemModel = new MenuItemModel(_db);
         vm.MenuItems = itemModel.GetAllByCategory(vm.Id);
     }
     return(View(vm));
 }
Example #5
0
        // GET: Admin/Category
        public ActionResult Index(int page = 1, int pageSize = 3)
        {
            var iplCategory  = new CategoryModel();
            var listCategory = iplCategory.GetAll().ToPagedList(page, pageSize);

            return(View(listCategory));
        }
Example #6
0
        private void FillSubcategory(String category)
        {
            this.comboBoxSubCategory.Items.Clear();

            var res = CategoryModel.GetAll();

            foreach (CategoryModel.Category x in res)
            {
                if (x.Name.Equals(category))
                {
                    if (x.Subcategory != null)
                    {
                        foreach (CategoryModel.Subcategory y in x.Subcategory)
                        {
                            this.comboBoxSubCategory.Items.Add(y.Name);
                        }

                        if (this.comboBoxSubCategory.Items.Count > 0)
                        {
                            this.comboBoxSubCategory.SelectedIndex = 0;
                        }
                    }

                    break;
                }
            }

            this.comboBoxSubCategory.DisplayMember = "Name";
            this.comboBoxSubCategory.ValueMember   = "Name";
        }
Example #7
0
        public static string GetRecommendedCategory(Transaction transaction)
        {
            var categories = CategoryModel.GetAll();
            var tags       = TagModel.GetAll();

            foreach (TagModel.Tag x in tags)
            {
                if (transaction.Description.Contains(x.Name))
                {
                    return(x.Category);
                }
            }

            return(null);
        }
Example #8
0
        private void FillCategory()
        {
            var res = CategoryModel.GetAll();

            foreach (CategoryModel.Category x in res)
            {
                this.comboBoxCategory.Items.Add(x.Name);
            }

            if (this.comboBoxCategory.Items.Count > 0)
            {
                this.comboBoxCategory.SelectedIndex = 0;
            }

            this.comboBoxCategory.DisplayMember = "Name";
            this.comboBoxCategory.ValueMember   = "Name";
        }
        public async Task <IActionResult> Details(int?id)
        {
            ViewBag.Loggedin = HttpContext.Session.GetInt32("authenticated").HasValue;
            if (id == null || !id.HasValue)
            {
                return(NotFound());
            }

            var product = await productModel.GetProduct(id.Value);

            if (product == null)
            {
                return(NotFound());
            }

            ViewBag.Categories = await categoryModel.GetAll();

            return(View(product));
        }
Example #10
0
        public IActionResult GetCategories()
        {
            CategoryModel model = new CategoryModel(_db);

            return(Ok(model.GetAll()));
        }