Exemple #1
0
        public async Task <IActionResult> Update(UseFullUpdateGetIputViewModel inputViewModel)
        {
            if (!this.User.IsInRole(GlobalConstants.AdministratorRoleName))
            {
                return(this.Redirect("/Identity/Account/AccessDenied"));
            }

            if (!this.ModelState.IsValid)
            {
                var error = new UseFullCategoryError
                {
                    ErrorMessage = GlobalConstants.UseFullCategoryModelValidationMessаge
                };
                return(this.RedirectToAction("Error", "UseFullCategory", error));
            }

            var dtoInputModel  = UseFullUpdateGetInputMapper.Map(inputViewModel);
            var dtoOutPutModel = await this.useFullCategoryService.GetDtoModelForUpdateOutputModelAsync(dtoInputModel);

            if (dtoOutPutModel == null)
            {
                var error = new UseFullCategoryError
                {
                    ErrorMessage = GlobalConstants.UseFullCategoryUpdateErrorMessage
                };
                return(this.RedirectToAction("Error", "UseFullCategory", error));
            }

            var viewModel = UseFullUpdateGetOutPutMapper.Map(dtoOutPutModel);

            return(this.View(viewModel));
        }
        public static UseFullUpdateGetInputDtoModel Map(UseFullUpdateGetIputViewModel viewModel)
        {
            var dtoInputModel = new UseFullUpdateGetInputDtoModel
            {
                UseFullCategoryId = viewModel.UseFullCategoryId
            };

            return(dtoInputModel);
        }