public IActionResult AddUserToWorkspace([FromBody] User user, string workspaceName) // frombody workspace object or string name { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var userAdded = iservice.AddUserToWorkspace(workspaceName, user); return(new ObjectResult(userAdded)); }
public IActionResult AddUserToWorkspace([FromBody] UserAccountView user, string workspaceName) // frombody workspace object or string name { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { // get the workspace in which user needs to be added var searchedWorkSpace = iservice.GetWorkspaceByName(workspaceName).Result; // check if user already added in workspace var userAlreadyInWorkspace = searchedWorkSpace.Users.Find(u => u.UserId == user.Id); if (userAlreadyInWorkspace != null) { // return error message if already added return(NotFound("User already added in Workspace")); } } catch { } // call service to add user to workspace var userAdded = iservice.AddUserToWorkspace(user, workspaceName).Result; return(new ObjectResult(userAdded)); }