public ActionResult AddTeacher(Teacher teacher)
 {
     if (!ModelState.IsValid)
     {
         return(View(teacher));
     }
     _teachersService.Add(teacher);
     return(Redirect("/Teachers/All"));
 }
예제 #2
0
 public IHttpActionResult Post([FromBody] string name)
 {
     try {
         var result = _teachersService.Add(name);
         return(ResultToHttpActionResult(result));
     }
     catch (FullNameIsEmptyOrSingleException)
     {
         return(BadRequest("Invalid name"));
     }
 }
예제 #3
0
 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"));
 }