public async Task <ActionResult> DeleteConfirmed(int id) { Category category = await db.Categories.FindAsync(id); db.Categories.Remove(category); await db.SaveChangesAsync(); await RedisLib.DeleteCache("Categories"); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Name")] Category category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; await db.SaveChangesAsync(); await RedisLib.DeleteCache("Categories"); return(RedirectToAction("Index")); } return(View(category)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name")] Category category) { if (ModelState.IsValid) { db.Categories.Add(category); await db.SaveChangesAsync(); await RedisLib.DeleteCache("Categories"); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult AddProductToDB(ProductViewModel product) { if (ModelState.IsValid) { if (this.unitOfWork.ProductRepo.AddProduct(product)) { unitOfWork.Complete(); return(RedirectToAction("Index", "Home")); } else { return(View("Create", product)); } } product.Categories = RedisLib.GetCache <IEnumerable <Category> >("Categories", () => { return(unitOfWork.CategoryRepo.AllCategories()); }); // CategoryRepository.AllCategories(); return(View("GetAllAction")); }