コード例 #1
0
 /// <summary>
 /// Post API/Classe
 /// </summary>
 /// <param name="Classe">Classe à insérer</param>
 public IHttpActionResult Post(ClasseModel Classe)
 {
     if ((new[] { "Admin" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (Classe == null || Classe.NameEN == null || Classe.NameFR == null)
         {
             return(BadRequest());
         }
         else
         {
             repo.Create(Classe.MapTo <ClasseEntity>());
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
コード例 #2
0
 public IActionResult Put(int id, [FromBody] ClasseModel Classe)
 {
     if ((new[] { "Admin" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (repo.GetOne(id) == null)
         {
             return(NotFound());
         }
         if (Classe == null || Classe.NameEN == null || Classe.NameFR == null)
         {
             return(BadRequest());
         }
         else
         {
             repo.Update(id, Classe.MapTo <ClasseEntity>());
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }