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)); }
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)); }
// 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)); }
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"; }
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); }
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)); }
public IActionResult GetCategories() { CategoryModel model = new CategoryModel(_db); return(Ok(model.GetAll())); }