Beispiel #1
0
        public static TownUpdateGetInputDtoModel Map(TownUpdateGetInputViewModel viewModel)
        {
            var dtoModel = new TownUpdateGetInputDtoModel
            {
                TownId = viewModel.TownId
            };

            return(dtoModel);
        }
Beispiel #2
0
        public async Task <IActionResult> Update(TownUpdateGetInputViewModel viewModel)
        {
            if (!this.User.IsInRole(GlobalConstants.AdministratorRoleName))
            {
                return(this.Redirect("/Identity/Account/AccessDenied"));
            }

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

            var dtoInputModel  = TownUpdateGetInputModelMapper.Map(viewModel);
            var dtoOutPutModel = await this.townService.GetTownById(dtoInputModel);

            var viewOutputModel = TownUpdateGetOutputMapper.Map(dtoOutPutModel);

            return(this.View(viewOutputModel));
        }