public ActionResult AddTeacher(Teacher teacher) { if (!ModelState.IsValid) { return(View(teacher)); } _teachersService.Add(teacher); return(Redirect("/Teachers/All")); }
public IHttpActionResult Post([FromBody] string name) { try { var result = _teachersService.Add(name); return(ResultToHttpActionResult(result)); } catch (FullNameIsEmptyOrSingleException) { return(BadRequest("Invalid name")); } }
public IActionResult Add(Persons model) { if (!ModelState.IsValid) { return(View(model)); } model.Uid = Guid.NewGuid(); _personsService.Add(model); _teachersService.Add(new Teachers() { PersonUid = model.Uid }); return(RedirectToAction("List")); }