Created
July 13, 2019 09:35
-
-
Save DmitrySikorsky/fff9ce6ea855b9fd0a1a992b2c85c640 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
[ExportModelStateToTempData] | |
public IActionResult AddOrEdit(AddOrEdit addOrEdit) | |
{ | |
if (!this.ModelState.IsValid) | |
return this.RedirectToAction("AddOrEdit"); | |
Data.Entities.Book book = addOrEdit.Id == null ? new Data.Entities.Book() : this.bookRepository.GetById((int)addOrEdit.Id); | |
this.CreateOrUpdateLocalizationsFor(book); | |
book.Year = addOrEdit.Year; | |
if (addOrEdit.Id == null) | |
this.bookRepository.Create(book); | |
else this.bookRepository.Update(book); | |
this.storage.SaveChanges(); | |
return this.RedirectToAction("Index"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment