public IActionResult Post(FavoriteStrategyModel Favori) { if ((new[] { "Admin", "User" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase)) { if (Favori == null || Favori.User.Id == 0 || Favori.Strategy.Id == 0) { return(BadRequest()); } else { repo.Create(Favori.ToEntity()); return(Ok()); } } else { return(Unauthorized()); } }
public IActionResult Put(int id, [FromBody] FavoriteStrategyModel Favori) { if ((new[] { "Admin", "User" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase)) { if (repo.GetOne(id) == null) { return(NotFound()); } else if (Favori == null || Favori.User.Id == 0 || Favori.Strategy.Id == 0) { return(BadRequest()); } else { repo.Update(id, Favori.ToEntity()); return(Ok()); } } else { return(Unauthorized()); } }