Пример #1
0
        public async Task EditCathedra(EditCathedraAdminView viewModel)
        {
            Company cathedra = await _companyRepository.Get(viewModel.Id);

            if (cathedra is null)
            {
                throw new AdminException("Entered cathedra doesn't exist.");
            }

            var changeCiphers = false;

            if (!(cathedra.Name.ToUpper().Equals(viewModel.Name.ToUpper())))
            {
                cathedra = await _companyRepository.FindCompanyByName(viewModel.Name);

                if (!(cathedra is null))
                {
                    throw new AdminException("Entered cathedra already exist.");
                }
            }

            _cathedraMapper.MapCathedraEditViewModelToCathedraModel(cathedra, viewModel);

            await _companyRepository.Update(cathedra);
        }
Пример #2
0
        public async Task <IActionResult> EditCathedra(EditCathedraAdminView viewModel)
        {
            try
            {
                await _adminService.EditCathedra(viewModel);

                return(RedirectToAction("ShowCathedras"));
            }
            catch (AdminException ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);

                EditCathedraDataAdminView result = await _adminService.EditCathedra(viewModel.Id);

                return(View("Cathedras/EditCathedra", result));
            }
        }
Пример #3
0
 public void MapCathedraEditViewModelToCathedraModel(Company model, EditCathedraAdminView viewModel)
 {
     model.Id   = viewModel.Id;
     model.Name = viewModel.Name;
 }