/// <summary> /// Post API/Vote /// </summary> /// <param name="E">Vote à insérer</param> public IHttpActionResult Post(VoteModel Vote) { if ((new[] { "Admin", "User" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase)) { if (Vote == null || Vote.Strategy.Id == 0 || Vote.User.Id == 0) { return(BadRequest()); } else { repo.Create(Vote.ToEntity()); return(Ok()); } } else { return(Unauthorized()); } }
public IActionResult Put(int id, [FromBody] VoteModel Vote) { if ((new[] { "Admin", "User" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase)) { if (repo.GetOne(id) == null) { return(NotFound()); } else if (Vote == null || Vote.Strategy.Id == 0 || Vote.User.Id == 0) { return(BadRequest()); } else { repo.Update(id, Vote.ToEntity()); return(Ok()); } } else { return(Unauthorized()); } }