Created
February 9, 2018 12:09
-
-
Save hudo/4637a0daf14c1818c9c2e9c873652cf0 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, ValidateAnyForgeryToken] | |
public async Task<IActionResult> Save(ProductModel model) | |
{ | |
if(!ModelState.IsValid) | |
return View(model); | |
// invoke some business logic magic that makes money | |
try | |
{ | |
await _dbContext.SaveChanges(); | |
} | |
catch(Exception e) | |
{ | |
_logger.LogError("message", e); | |
ModelState.AddModelError("exception", "Houston we have a problem:" + e.Message); | |
return View(model); | |
} | |
return RedirectToActio("Read", new { id = model.Id }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment