public HttpResponseMessage AddRole(Role role) { HttpResponseMessage response = null; try { if (role != null) { RoleModel existing_instance = RoleRepo.GetExistingRole(role); if (existing_instance != null) { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_701", "Role already exists", "Role already exists")); } else { RoleRepo.CreateRole(role); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Role created Successfully!", "Role created Successfully!")); } } else { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_102", "Failure", "Please check the Json input")); } } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message)); } return(response); }