public ActionResult AddModel() { AddEditModel Setupadd = new AddEditModel(); Setupadd.SetMakeChoices(); return(View(Setupadd)); }
public AddEditView() { InitializeComponent(); addEditModel = new AddEditModel(); cbCategory.Items.Add("Hot"); cbCategory.Items.Add("Warm"); cbCategory.Items.Add("Cold"); }
public IActionResult AddEdit(AddEditModel model) { var entity = model.MapTo <Department>(); var result = model.Id.IsNullOrWhiteSpace() ? _departmentService.Add(entity) : _departmentService.Update(entity); return(Json(result)); }
public ActionResult AddModel2(AddEditModel ToAdd) { CarRepoADO repo = new CarRepoADO(); AddEditModel forview = new AddEditModel(); if (ModelState.IsValid) { CarModels AddME = new CarModels(); AddME.ModelName = ToAdd.ModelName; AddME.MakeID = ToAdd.MakeID; repo.AddModel(AddME); forview.SetMakeChoices(); return(View("AddModel", forview)); } else { ToAdd.SetMakeChoices(); return(View("AddModel", ToAdd)); } }
public ActionResult AddModel(AddEditModel ToAdd) { CarRepoADO repo = new CarRepoADO(); AddEditModel forview = new AddEditModel(); forview.SetMakeChoices(); if (!string.IsNullOrWhiteSpace(ToAdd.ModelToAdd.ModelName)) { CarModels AddME = new CarModels(); AddME.ModelName = ToAdd.ModelToAdd.ModelName; AddME.MakeID = ToAdd.ModelToAdd.MakeID; repo.AddModel(AddME); return(View("AddModel", forview)); } else { ToAdd.SetMakeChoices(); return(View("AddModel", ToAdd)); } }
public IActionResult AddEdit(AddEditModel model) { var isNameExists = _menuService.IsNameExists(model.Id, model.Name); if (isNameExists.Failed) { return(Json(isNameExists)); } var entity = model.MapTo <Menu>(); if (model.Id.IsNullOrWhiteSpace()) { _menuService.Add(entity); } else { _menuService.Update(entity); } return(Json(ServiceResult.IsSuccess("操作成功"))); }