public IActionResult Post([FromBody] StrategyModel Strategy)
 {
     if ((new[] { "Admin", "User", "Anonymous" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (Strategy == null || Strategy.ImagePath1 == null || Strategy.ImagePath2 == null || Strategy.ImagePath3 == null || Strategy.ImagePath4 == null || Strategy.CharactersConfiguration.Id == 0 || Strategy.User.Id == 0 || Strategy.BossZone.Id == 0)
         {
             return(BadRequest());
         }
         else
         {
             repo.Create(Strategy.ToEntity());
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
Beispiel #2
0
 /// <summary>
 /// Put API/Strategy/{id}
 /// </summary>
 /// <param name="Strategy">Strategy à insérer</param>
 /// <param name="id">Id de l'Strategy à Updateier</param>
 public IHttpActionResult Put(int id, StrategyModel Strategy)
 {
     if ((new[] { "Admin", "User" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (repo.GetOne(id) == null)
         {
             return(NotFound());
         }
         else if (Strategy == null || Strategy.ImagePath1 == null || Strategy.ImagePath2 == null || Strategy.ImagePath3 == null || Strategy.ImagePath4 == null || Strategy.CharactersConfiguration.Id == 0 || Strategy.User.Id == 0 || Strategy.BossZone.Id == 0)
         {
             return(BadRequest());
         }
         else
         {
             repo.Update(id, Strategy.ToEntity());
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }