public void GetOne()
        {
            var Cxt = new VendsRepository(connexion);

            var vente = new Vends
            {
                DateVente    = new DateTime(),
                IdPermaFungi = 1,
                IdProduit    = 2
            };

            CompositeKey <int, int> id = new CompositeKey <int, int> {
                PK1 = 2, PK2 = 2
            };

            Assert.IsNotNull(Cxt.GetOne(id));
        }
Beispiel #2
0
 public HttpResponseMessage delete(int idPF, int idProd)
 {
     try
     {
         VendsRepository VenteRepo   = new VendsRepository(connexion);
         var             compositKey = new CompositeKey <int, int>();
         compositKey.PK1 = idPF;
         compositKey.PK2 = idProd;
         var venteToDelete = VenteRepo.GetOne(compositKey);
         if (venteToDelete == null)
         {
             return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Vente with ID: " + compositKey.ToString() + "not found"));
         }
         VenteRepo.Delete(compositKey);
         return(Request.CreateResponse(HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, ex));
     }
 }
Beispiel #3
0
        public HttpResponseMessage Get(int idPF, int idProd)
        {
            VendsRepository      VenteRepo = new VendsRepository(connexion);
            PermaFungiRepository PFRepo    = new PermaFungiRepository(connexion);
            ProduitRepository    prodRepo  = new ProduitRepository(connexion);


            var compositKey = new CompositeKey <int, int>();

            compositKey.PK1 = PFRepo.GetOne(idPF).Id;
            compositKey.PK2 = prodRepo.GetOne(idProd).Id;
            var result = VenteRepo.GetOne(compositKey);

            if (result != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, result));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, "Vente with ID: " + compositKey.ToString() + "not found"));
            }
        }