Пример #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                if (await _eyeColorService.UpdateEyeColorAsync(EyeColor) != null)
                {
                    // success
                    TempData["Success"] = "EyeColor Successfully edited.";
                    return(RedirectToPage("Index"));
                }
                else
                {
                    // db failure
                    ViewData["Message"] = "Database error, contact the developer to fix the error.";

                    _logger.LogError($"EyeColor {nameof(EditModel)} database error.");

                    return(Page());
                }
            }

            // invalid inputs by admin
            ViewData["Message"] = "your inputs is not valid.";

            _logger.LogError($"EyeColor {nameof(EditModel)} invalid inputs.");

            return(Page());
        }
Пример #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                if (await _eyeColorService.UpdateEyeColorAsync(EyeColor) != null)
                {
                    TempData["Success"] = "EyeColor successfully updated.";
                    return(RedirectToPage("Index"));
                }
                else
                {
                    ViewData["Message"] = "Database error,Contact the developer to fix the error.";

                    _logger.LogError($"EyeColor {nameof(EditModel)} database error! ");

                    return(Page());
                }
            }

            ViewData["Message"] = "Your input is not valid";

            _logger.LogError($"EyeColor {nameof(EditModel)} database error! ");

            return(Page());
        }