コード例 #1
0
 //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));
     }
 }
コード例 #2
0
        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");
        }
コード例 #3
0
 //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));
     }
 }