public HttpResponseMessage Post([FromBody] StudentViewModel StudentViewModel) { try { if (_student.CheckStudentExits(StudentViewModel.Name)) { var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.Conflict }; return(response); } else { var userId = this.User.FindFirstValue(ClaimTypes.Name); var tempStudent = AutoMapper.Mapper.Map <Student>(StudentViewModel); tempStudent.CreatedBy = Convert.ToInt32(userId); _student.InsertStudent(tempStudent); var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.OK }; return(response); } } catch (Exception ex) { var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.InternalServerError }; return(response); } }