public async Task <ActionResult <UniversityDTO> > Create([FromBody] UniversityDTO universityDTO) { if (universityDTO == null) { universityDTO = new UniversityDTO(); } University university = ConvertDTOtoBO(universityDTO); university = await UniversityService.Create(university); universityDTO = new UniversityDTO { Id = university.Id, Code = university.Code, Name = university.Name, Address = university.Address, Website = university.Website, Errors = university.Errors }; if (university.HasError) { return(BadRequest(universityDTO)); } return(Ok(universityDTO)); }
public ActionResult Add(UniversityDto universityDto) { if (!ModelState.IsValid) { return(View(universityDto)); } var university = Mapper.Map <UniversityDto, University>(universityDto); university.CityId = universityDto.CityId; university.UniversityTypeId = universityDto.UniversityTypeId; _universityService.Create(university); return(RedirectToAction("List")); }