Exemple #1
0
		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);
			}
		}
Exemple #2
0
	    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);
		    }
	    }