public ActionResult Create(CreateWorkType formModel) { var repo = new WorkTypeRepo(context); try { var newWorkType = new WorkType(0, formModel.Name, formModel.Rate); repo.Insert(newWorkType); return(RedirectToAction("Index")); } catch (DbUpdateException ex) { HandleDbUpdateException(ex); } return(View("Create", formModel)); }
public ActionResult Create(CreateWorkType workType) { WorkTypeRepository repo = new WorkTypeRepository(context); try { WorkType newWorkType = new WorkType(0, workType.Name, workType.Rate); repo.Insert(newWorkType); return(RedirectToAction("Index")); } catch (DbUpdateException ex) { HandleDbUpdateException(ex); } return(View("Create", workType)); }
public ActionResult Create(CreateWorkType formModel) { var repo = new WorkTypeRepository(_context); WorkType workType = new WorkType(formModel.Name, formModel.Rate); try { repo.Insert(workType); return(RedirectToAction("Index")); } catch (SqlException se) { if (se.Number == 2627) { ModelState.AddModelError("Name", "That name is already taken."); } } return(View(formModel)); }
public ActionResult Create(CreateWorkType workType) { WorkTypeRepository repo = new WorkTypeRepository(); try { WorkType newWorkType = new WorkType(0, workType.Name, workType.Rate); repo.Insert(newWorkType); return(RedirectToAction("Index")); } catch (SqlException se) { if (se.Number == 2627) { ModelState.AddModelError("Name", "That name is already taken."); } } return(View("Create", workType)); }
public ActionResult Create() { var workType = new CreateWorkType(); return(View("Create", workType)); }
public ActionResult Create() { var formModel = new CreateWorkType(); return(View(formModel)); }