public IHttpActionResult Post([FromBody] MajorDto form) { if (ModelState.IsValid) { try { var major = Mapper.Map <MajorDto, Major>(form); _majorService.Add(major); var majorDto = GetMajorDto(major); return(Created(new Uri(majorDto.Url), majorDto)); } catch (ArgumentNullException ane) { ModelState.AddModelError("", ane.Message); } catch (PreexistingEntityException pe) { ModelState.AddModelError("", pe.Message); } } return(BadRequest(ModelState)); }