public ActionResult Create(StudentViewModel student) { var studentServiceModel = AutoMapper.Mapper.Map <StudentViewModel, Students.ServicesModel.Student>(student); _studentsService.Create(studentServiceModel); return(RedirectToAction("Students")); //new HttpStatusCodeResult(HttpStatusCode.Created); }
public IHttpActionResult Post([FromBody] StudentModel student) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = _studentsService.Create(_mapper.Map <StudentModel, StudentDetails>(student), student.CourseId.Value); return(ResultToHttpActionResult(result, x => _mapper.Map <StudentDetails, StudentViewModel>(x))); }