public HttpResponseMessage Post([FromBody] TeacherViewModel teacher) { if (ModelState.IsValid) { int userId = Convert.ToInt32(this.User.FindFirstValue(ClaimTypes.Name)); int coorid = _coordinator.GetCoordinatorId(userId); var tempUsers = AutoMapper.Mapper.Map <Users>(teacher); tempUsers.CreatedDate = DateTime.Now; tempUsers.Createdby = userId; tempUsers.Password = EncryptLib.EncryptText(teacher.Password); _users.InsertUsers(tempUsers); var tempTeacher = AutoMapper.Mapper.Map <Teacher>(teacher); tempTeacher.DepartmentId = _coordinator.GetCoordinatorDepartmentId(coorid); tempTeacher.CreatedBy = coorid; tempTeacher.UserID = tempUsers.UserId; _teacher.InsertTeacher(tempTeacher); UsersInRoles usersInRoles = new UsersInRoles(); usersInRoles.RoleId = 3; usersInRoles.UserId = tempTeacher.UserID; _usersInRoles.AssignRole(usersInRoles); var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.OK }; return(response); } else { var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest }; return(response); } }