Exemple #1
0
 public void UpdateUser(User user)
 {
     using (Entities.AppContext appContext = new Entities.AppContext())
     {
         appContext.Entry <User>(user).State = EntityState.Modified;
         appContext.SaveChanges();
     }
 }
Exemple #2
0
 public void AddTypeOfShop(TypeOfShop typeOfShop)
 {
     using (Entities.AppContext appContext = new Entities.AppContext())
     {
         appContext.TypeOfShops.Add(typeOfShop);
         appContext.SaveChanges();
     }
 }
Exemple #3
0
 public void AddShop(Shop shop)
 {
     using (Entities.AppContext appContext = new Entities.AppContext())
     {
         appContext.Shops.Add(shop);
         appContext.SaveChanges();
     }
 }
Exemple #4
0
 public void UpdateShop(Shop shop)
 {
     using (Entities.AppContext appContext = new Entities.AppContext())
     {
         appContext.Entry <Shop>(shop).State = EntityState.Modified;
         appContext.SaveChanges();
     }
 }
Exemple #5
0
 public void AddDemandeOption(DemandeOption opt)
 {
     using (Entities.AppContext context = new Entities.AppContext())
     {
         context.DemandeOptions.Add(opt);
         context.SaveChanges();
     }
 }
Exemple #6
0
 public void SignUp(User user)
 {
     using (Entities.AppContext appContext = new Entities.AppContext())
     {
         appContext.Users.Add(user);
         appContext.SaveChanges();
     }
 }
Exemple #7
0
 public void UpdateTypeOfShop(TypeOfShop typeOfShop)
 {
     using (Entities.AppContext appContext = new Entities.AppContext())
     {
         appContext.Entry <TypeOfShop>(typeOfShop).State = EntityState.Modified;
         appContext.SaveChanges();
     }
 }
Exemple #8
0
 public void UpdateAddress(Address address)
 {
     using (Entities.AppContext appContext = new Entities.AppContext())
     {
         appContext.Entry <Address>(address).State = EntityState.Modified;
         appContext.SaveChanges();
     }
 }
Exemple #9
0
 public void AddAddress(Address address)
 {
     using (Entities.AppContext appContext = new Entities.AppContext())
     {
         appContext.Addresses.Add(address);
         appContext.SaveChanges();
     }
 }
Exemple #10
0
 public void UpdateDemandeOption(DemandeOption option)
 {
     using (Entities.AppContext context = new Entities.AppContext())
     {
         DemandeOption optionToSave = (from opt in context.DemandeOptions where (opt.IdChambreReservee == option.IdChambreReservee) && (opt.IdOption == option.IdOption) select opt).SingleOrDefault <DemandeOption>();
         optionToSave.IdOption          = option.IdOption;
         optionToSave.IdChambreReservee = option.IdChambreReservee;
         optionToSave.NbJour            = option.NbJour;
         context.SaveChanges();
     }
 }
Exemple #11
0
 public void AddChambre(Chambre chambre)
 {
     using (Entities.AppContext context = new Entities.AppContext())
     {
         if (chambre != null)
         {
             context.Chambres.Add(chambre);
             context.SaveChanges();
         }
     }
 }
Exemple #12
0
 public void RemoveChambreReservee(int?id)
 {
     using (Entities.AppContext context = new Entities.AppContext())
     {
         ChambreReservee crToRemove = context.ChambreReservees.Find(id);
         if (crToRemove != null)
         {
             context.ChambreReservees.Remove(crToRemove);
             context.SaveChanges();
         }
     }
 }
Exemple #13
0
 public int AddChambreReservee(ChambreReservee cr)
 {
     using (Entities.AppContext context = new Entities.AppContext())
     {
         if (cr != null)
         {
             context.ChambreReservees.Add(cr);
             context.SaveChanges();
         }
     }
     return(cr.Id);
 }
Exemple #14
0
 public void RemoveClient(int?id)
 {
     using (Entities.AppContext context = new Entities.AppContext())
     {
         Client clientToRemove = context.Clients.Find(id);
         if (clientToRemove != null)
         {
             context.Clients.Remove(clientToRemove);
             context.SaveChanges();
         }
     }
 }
Exemple #15
0
 public int AddClient(Client client)
 {
     using (Entities.AppContext context = new Entities.AppContext())
     {
         if (client != null)
         {
             context.Clients.Add(client);
             context.SaveChanges();
         }
     }
     return(client.IdentifiantCli);
 }
Exemple #16
0
 public void RemoveReservation(int?id)
 {
     using (Entities.AppContext context = new Entities.AppContext())
     {
         Reservation resaToRemove = context.Reservations.Find(id);
         if (resaToRemove != null)
         {
             context.Reservations.Remove(resaToRemove);
             context.SaveChanges();
         }
     }
 }
Exemple #17
0
 public void SetRate(Rating rating, User user, Shop shop, int rate)
 {
     using (Entities.AppContext appContext = new Entities.AppContext())
     {
         rating.User   = user;
         rating.Shop   = shop;
         rating.IdUser = user.IdUser;
         rating.IdShop = shop.IdShop;
         rating.Rate   = rate;
         appContext.Entry <Rating>(rating).State = EntityState.Modified;
         appContext.SaveChanges();
     }
 }
Exemple #18
0
 public int AddReservation(Reservation resa)
 {
     using (Entities.AppContext context = new Entities.AppContext())
     {
         if (resa != null)
         {
             resa.DateReservation = DateTime.Now;
             context.Reservations.Add(resa);
             context.SaveChanges();
         }
     }
     return(resa.IdentifiantRes);
 }
Exemple #19
0
 public void UpdateReservation(Reservation resa)
 {
     using (Entities.AppContext context = new Entities.AppContext())
     {
         Reservation resaToUpdate = context.Reservations.Find(resa.IdentifiantCli);
         if (resaToUpdate != null)
         {
             resaToUpdate.IdentifiantCli  = resa.IdentifiantCli;
             resaToUpdate.DateDebutSejour = resa.DateDebutSejour;
             resaToUpdate.NbNuits         = resa.NbNuits;
             context.SaveChanges();
         }
     }
 }
Exemple #20
0
 public void UpdateClient(Client client)
 {
     using (Entities.AppContext context = new Entities.AppContext())
     {
         Client clientToUpdate = context.Clients.Find(client.IdentifiantCli);
         if (clientToUpdate != null)
         {
             clientToUpdate.Nom       = client.Nom;
             clientToUpdate.Prenom    = client.Prenom;
             clientToUpdate.Telephone = client.Telephone;
             clientToUpdate.Email     = client.Email;
             context.SaveChanges();
         }
     }
 }
Exemple #21
0
 public void UpdateChambreReservee(ChambreReservee cr)
 {
     using (Entities.AppContext context = new Entities.AppContext())
     {
         ChambreReservee crToUpdate = context.ChambreReservees.Find(cr.Id);
         if (crToUpdate != null)
         {
             crToUpdate.Id             = cr.Id;
             crToUpdate.IdentifiantRes = cr.IdentifiantRes;
             crToUpdate.Numero         = cr.Numero;
             crToUpdate.NbPersonne     = cr.NbPersonne;
             context.SaveChanges();
         }
     }
 }
Exemple #22
0
 public void UpdateChambre(Chambre chambre)
 {
     using (Entities.AppContext context = new Entities.AppContext())
     {
         Chambre chambresToUpdate = context.Chambres.Find(chambre.Numero);
         if (chambresToUpdate != null)
         {
             chambresToUpdate.Numero            = chambre.Numero;
             chambresToUpdate.NumEtage          = chambre.NumEtage;
             chambresToUpdate.NbLit             = chambre.NbLit;
             chambresToUpdate.LitEnfant         = chambre.LitEnfant;
             chambresToUpdate.LitDouble         = chambre.LitDouble;
             chambresToUpdate.DateDernierMenage = chambre.DateDernierMenage;
             context.SaveChanges();
         }
     }
 }
Exemple #23
0
 public Repas Enregistrer(Repas repas)
 {
     using (Entities.AppContext context = new Entities.AppContext())
     {
         if (repas.Id > 0)
         {
             context.Repas.Attach(repas);
             context.Entry(repas).State = System.Data.Entity.EntityState.Modified;
         }
         else
         {
             context.Repas.Add(repas);
         }
         context.SaveChanges();
     }
     return(repas);
 }
Exemple #24
0
 public Client Enregistrer(Client cli)
 {
     using (Entities.AppContext context = new Entities.AppContext())
     {
         if (cli.IdentifiantCli > 0)
         {
             context.Clients.Attach(cli);
             context.Entry(cli).State = System.Data.Entity.EntityState.Modified;
         }
         else
         {
             context.Clients.Add(cli);
         }
         context.SaveChanges();
     }
     return(cli);
 }
Exemple #25
0
 public bool Supprimer(Client client)
 {
     try
     {
         using (Entities.AppContext context = new Entities.AppContext())
         {
             context.Clients.Attach(client as Client);
             context.Clients.Remove(client as Client);
             context.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
     }
     return(false);
 }
Exemple #26
0
 public void RemoveOption(DemandeOption option)
 {
     using (Entities.AppContext context = new Entities.AppContext())
     {
         try
         {
             DemandeOption optionToRemove = (from opt in context.DemandeOptions where (opt.IdChambreReservee == option.IdChambreReservee) && (opt.IdOption == option.IdOption) select opt).SingleOrDefault <DemandeOption>();
             if (optionToRemove != null)
             {
                 context.DemandeOptions.Remove(optionToRemove);
                 context.SaveChanges();
             }
         }
         catch (Exception e)
         {
             return;
         }
     }
 }