//create public HttpResponseMessage Post([FromBody] PermaFungiClass PF) { try { PermaFungiRepository PFRepo = new PermaFungiRepository(connexion); PFRepo.Insert(PF); return(Request.CreateResponse(HttpStatusCode.Created, PF)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public void GetOne() { var Cxt = new PermaFungiRepository(connexion); var Permafungi = new PermaFungiClass { Adresse = "rue de l'espoir", Contact = "David", Email = "*****@*****.**", Ville = "chl" }; var newPermafungi = Cxt.Insert(Permafungi); Assert.AreEqual(Cxt.GetOne(newPermafungi.IdPermaFungi).Ville, "chl"); }
//update public HttpResponseMessage Put([FromBody] PermaFungiClass PF) { try { PermaFungiRepository PFRepo = new PermaFungiRepository(connexion); if (PF == null) { return(Request.CreateResponse(HttpStatusCode.NotFound, "PermaFungi Not Found")); } PFRepo.Update(PF); return(Request.CreateResponse(HttpStatusCode.OK, PF)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }