public async Task <IActionResult> OnPostAsync() { if (ModelState.IsValid) { // admin inputs is valid if (await _patternServicee.AddPatternAsync(Pattern) != null) { // success TempData["Success"] = "New Pattern successfully added."; return(RedirectToPage("Index")); } else { // db failure ViewData["Message"] = "Database error, contact the developer to fix the error."; _logger.LogError($"EyeColor {nameof(CreateModel)} database error."); return(Page()); } } // invalid inputs by admin ViewData["Message"] = "Your inputs is not valid."; _logger.LogError($"EyeColor {nameof(CreateModel)} invalid inputs."); return(Page()); }
public async Task <IActionResult> OnPostAsync() { if (ModelState.IsValid) { if (await _patternService.AddPatternAsync(Pattern) != null) { TempData["Success"] = "New Pattern successfully added."; return(RedirectToPage("Index")); } else { ViewData["Message"] = "Database error,Contact the developer to fix the error."; _logger.LogError($"Pattern {nameof(CreateModel)} database error! "); return(Page()); } } ViewData["Message"] = "Your input is not valid"; _logger.LogError($"Pattern {nameof(CreateModel)} database error! "); return(Page()); }