public ActionResult Save(BrandModel obj) { bool check = true; if (Request.IsAuthenticated) { if (obj.id > 0) { check = BrandDal.Update(obj); } else { check = BrandDal.Create(obj); } if (check) { TempData["message"] = "Saved successfully"; } else { TempData["message"] = "Error while saving data"; } return RedirectToAction("Create", "Brand"); } else { return RedirectToAction("index", "home"); } }
public ActionResult Create() { if (Request.IsAuthenticated) { ViewBag.PageTittle = "Add Brand"; ViewBag.breadCrum = "<a href='/Admin/Brand/index'>Brand</a> >> Add Brand"; BrandModel obj = new BrandModel(); return View(obj); } else { return RedirectToAction("index", "home"); } }
public static bool Create(BrandModel obj) { bool check = true; try { var context = new Ecommerce.DbEntity.ecommerceEntities(); context.brands.Add(new DbEntity.brand { BrandName = obj.BrandName}); context.SaveChanges(); } catch (Exception ex) { check = false; } return check; }
public static bool Update(BrandModel obj) { bool check = true; try { var context = new Ecommerce.DbEntity.ecommerceEntities(); var Brand = context.brands.Where(m => m.id == obj.id).FirstOrDefault(); Brand.BrandName = obj.BrandName; context.SaveChanges(); } catch (Exception ex) { check = false; } return check; }