Пример #1
0
        public Company MapToCathedraModel(CreateCathedraAdminView viewModel)
        {
            var model = new Company();

            model.Name = viewModel.Name;

            return(model);
        }
Пример #2
0
        public async Task CreateCathedra(CreateCathedraAdminView viewModel)
        {
            Company cathedra = await _companyRepository.FindCompanyByName(viewModel.Name);

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

            cathedra = _cathedraMapper.MapToCathedraModel(viewModel);

            await _companyRepository.Create(cathedra);
        }
Пример #3
0
        public async Task <IActionResult> CreateCathedra(CreateCathedraAdminView viewModel)
        {
            try
            {
                await _adminService.CreateCathedra(viewModel);

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

                CreateCathedraDataAdminView result = await _adminService.LoadDataForCreateCathedraPage();

                return(View("Cathedras/CreateCathedra", result));
            }
        }