public ActionResult Edit(CarBrandFormStub model) { //bool isNameExist = RepoKompetitor.Find().Where(p => p.name == model.Name && p.id != model.Id).Count() > 0; if (ModelState.IsValid) { car_brand dbItem = RepoCarBrand.FindByPk(model.Id); dbItem = model.GetDbObject(dbItem); try { RepoCarBrand.Save(dbItem); } catch (Exception e) { return(View("Form", model)); } //message string template = HttpContext.GetGlobalResourceObject("MyGlobalMessage", "CreateSuccess").ToString(); this.SetMessage(model.Name, template); return(RedirectToAction("Index")); } else { car_brand car_brand = RepoCarBrand.FindByPk(model.Id); ViewBag.name = car_brand.name; return(View("Form", model)); } }
public ActionResult Create(CarBrandFormStub model) { //bool isNameExist = RepoCarBrand.Find().Where(p => p.name == model.Name).Count() > 0; if (ModelState.IsValid) { car_brand dbItem = new car_brand(); dbItem = model.GetDbObject(dbItem); RepoCarBrand.Save(dbItem); //message string template = HttpContext.GetGlobalResourceObject("MyGlobalMessage", "CreateSuccess").ToString(); this.SetMessage(model.Name, template); return(RedirectToAction("Index")); } else { return(View("Form", model)); } }