public async Task<IHttpActionResult> AddUser(UserDTO model) { if (ModelState.IsValid) { try { await _userService.Save(model); return this.Ok(); } catch (Exception ex) { return this.BadRequest(ex.Message); } } else { return this.BadRequest(ModelState); } }
public async Task<IHttpActionResult> AssignUser(UserDTO model) { try { var user = await _userService.Get(model.UserId); var school = await _schoolService.Get(model.SchoolId); if (!school.Users.Contains(user)) school.Users.Add(user); await _schoolService.Save(school); return this.Ok(); } catch (Exception ex) { return this.BadRequest(ex.Message); } }