コード例 #1
0
 public ActionResult Create([FromBody] WriterCreateModel writer)
 {
     _writerRepository.Add(new Writer
     {
         FirstName   = writer.FirstName,
         LastName    = writer.LastName,
         DateOfBirth = writer.DateOfBirth,
         Biography   = writer.Biography
     });
     return(Ok(writer));
 }
コード例 #2
0
 public async Task <IActionResult> Create([Bind("FirstName,LastName,DateOfBirth,Biography")] WriterCreateModel writer)
 {
     if (ModelState.IsValid)
     {
         _writerRepository.Add(new Writer
         {
             FirstName   = writer.FirstName,
             LastName    = writer.LastName,
             DateOfBirth = writer.DateOfBirth,
             Biography   = writer.Biography
         });
         return(RedirectToAction("Index"));
     }
     return(View(writer));
 }