/// <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()); } }
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()); } }