public Company MapToCathedraModel(CreateCathedraAdminView viewModel) { var model = new Company(); model.Name = viewModel.Name; return(model); }
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); }
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)); } }