コード例 #1
0
 public ActionResult Add(AuthorModel model)
 {
     if (ModelState.IsValid)
     {
         new AuthorRepository().Insert(new Author
             {
                 FirstName = model.FirstName,
                 LastName = model.LastName
             });
         return RedirectToAction("Index", new { message = (int)AuthorsListSuccessMessage.AuthorAddedSuccesfully });
     }
     model.IsEditMode = false;
     return View("Edit", model);
 }
コード例 #2
0
 public ActionResult Edit(AuthorModel model)
 {
     if (ModelState.IsValid)
     {
         new AuthorRepository().Save(new Author
         {
             Id = model.Id,
             FirstName = model.FirstName,
             LastName = model.LastName
         });
         return RedirectToAction("Index", new { message = (int)AuthorsListSuccessMessage.AuthorEditedSuccesfully });
     }
     model.IsEditMode = true;
     return View(model);
 }