Example #1
0
        public async Task <ActionResult> Edit(Product product)
        {
            if (ModelState.IsValid)
            {
                db.Entry(product).State = EntityState.Modified;
                await db.SaveChangesAsync(CancellationToken.None);

                //Invalidate the cache entry as it is modified
                MemoryCache.Default.Remove(string.Format("product_{0}", product.ProductId));
                return(RedirectToAction("Index"));
            }

            ViewBag.Categories = new SelectList(db.Categories, "CategoryId", "Name", product.CategoryId);
            return(View(product));
        }