public HttpResponseMessage CreateRole([FromBody] RoleViewModel roleVM) { try { if (ModelState.IsValid) { if (_roleService.CheckRoleExits(roleVM.RoleName)) { HttpResponseMessage response = new HttpResponseMessage() { StatusCode = HttpStatusCode.Conflict }; return(response); } else { string userId = User.FindFirstValue(ClaimTypes.Name); RoleMaster role = Mapper.Map <RoleMaster>(roleVM); role.IsActive = true; role.CreatedDate = DateTime.Now; role.CreatedBy = Convert.ToInt32(userId); if (role != null) { _roleService.InsertRole(role); } HttpResponseMessage response = new HttpResponseMessage() { StatusCode = HttpStatusCode.OK }; return(response); } } else { HttpResponseMessage response = new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest }; return(response); } } catch (System.Exception ex) { throw ex; } }