public ActionResult Create(CarModelFormStub model) { //bool isNameExist = RepoCarModel.Find().Where(p => p.name == model.Name).Count() > 0; if (ModelState.IsValid) { car_model dbItem = new car_model(); dbItem = model.GetDbObject(dbItem); try { RepoCarModel.Save(dbItem); } catch (Exception e) { model.FillCarBrandOptions(RepoCarBrand.FindAll()); return(View("Form", model)); } //message string template = HttpContext.GetGlobalResourceObject("MyGlobalMessage", "CreateSuccess").ToString(); this.SetMessage(model.Name, template); return(RedirectToAction("Index")); } else { model.FillCarBrandOptions(RepoCarBrand.FindAll()); return(View("Form", model)); } }
public ActionResult Create() { List <Business.Entities.car_brand> listCarBrand = RepoCarBrand.FindAll(); CarModelFormStub formStub = new CarModelFormStub(listCarBrand); return(View("Form", formStub)); }
public ActionResult Index() { var model = new CarModelFormStub(); model.FillCarBrandOptions(RepoCarBrand.FindAll()); ViewBag.ListBrand = new JavaScriptSerializer().Serialize(model.CarBrandOptions); return(View()); }
public ActionResult Edit(Guid id) { car_model car_model = RepoCarModel.FindByPk(id); List <Business.Entities.car_brand> listCarBrand = RepoCarBrand.FindAll(); CarModelFormStub formStub = new CarModelFormStub(car_model, listCarBrand); ViewBag.name = car_model.name; return(View("Form", formStub)); }