コード例 #1
0
        public Company MapToCathedraModel(CreateCathedraAdminView viewModel)
        {
            var model = new Company();

            model.Name = viewModel.Name;

            return(model);
        }
コード例 #2
0
ファイル: AdminService.cs プロジェクト: EldarMamishev/ITT
        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));
            }
        }