Ejemplo n.º 1
0
 public ActionResult Edit(BrandModel model)
 {
     if (ModelState.IsValid)
     {
         using (_dbContext = new karrykartEntities())
         {
             var brand = _dbContext.Brands.Find(model.BrandID);
             brand.Name = model.Name;
             _dbContext.Entry(brand).State = System.Data.Entity.EntityState.Modified;
             _dbContext.SaveChanges();
             _logger.WriteLog(CommonHelper.MessageType.Success, "The brand is edited successfully with id=" + brand.BrandID, "Edit", "BrandController", User.Identity.Name);
             Success("The brand is edit successfully.", true);
             return RedirectToAction("Index", "Brand");
         }
     }
     return View(model);
 }
Ejemplo n.º 2
0
 public ActionResult Create(BrandModel model)
 {
     if (ModelState.IsValid)
     {
         using (_dbContext = new karrykartEntities())
         {
             var brand = new Brand();
             brand.Name = model.Name;
             _dbContext.Brands.Add(brand);
             _dbContext.SaveChanges();
             _logger.WriteLog(CommonHelper.MessageType.Success, "Brand add successfully with id=" + brand.BrandID, "Create", "BrandController", User.Identity.Name);
             Success("The brand is added successfully.", true);
             return RedirectToAction("Index", "Brand");
         }
     }
     return View();
 }