Пример #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            var newCategory = new CategoryDTO();

            if (await TryUpdateModelAsync <CategoryDTO>(
                    newCategory,
                    "category",
                    c => c.CategoryName, c => c.CategoryDescription))
            {
                await _categoryService.AddNewCategoryAsync(newCategory);

                ToastMessage = _locService.GetLocalizedString("Record added");
                ToastType    = "success";
                _logger.LogWarning($"Category '{newCategory.CategoryName}' was created by '{User.Identity.Name}'.");
                return(RedirectToPage("./Create"));
            }
            _logger.LogError($"Unknown error while trying to create a new category.");
            return(Page());
        }