public int SaveBills(int idclient, Facture facture) { var client = db.Client.Where(x => x.Id == idclient).FirstOrDefault(); client.Facture.Add(facture); db.SaveChanges(); return(db.Facture.Where(x => x.IdClient == idclient).Select(x => x.Id).LastOrDefault()); }
public void SaveReservation(Reservation reservation, int idclient, short numero) { var client = db.Client.AsNoTracking().Where(x => x.Id == idclient).FirstOrDefault(); int nbjour = 0; for (int i = 0; i < reservation.NombreDeJour; i++) { Reservation res = new Reservation(); res.NumChambre = numero; res.NbPersonnes = reservation.NbPersonnes; res.Travail = reservation.Travail; if (nbjour == 0) { res.NombreDeJour = reservation.NombreDeJour; } else { res.NombreDeJour = 0; } res.JourNavigation = db.Calendrier.Where(x => x.Jour == reservation.Jour.AddDays(i)).FirstOrDefault(); res.HeureArrivee = reservation.HeureArrivee; client.Reservation.Add(res); db.Update(client); db.SaveChanges(); nbjour++; } }
public void adddata() { CultureInfo ci = CultureInfo.InvariantCulture; var reserv = new List <Reservation>() { new Reservation() { NumChambre = 1, Jour = DateTime.ParseExact("2019-01-01", "yyyy-MM-dd", ci), IdClient = 2, NbPersonnes = 2, HeureArrivee = 18 }, //Child entity (empty key) new Reservation() { NumChambre = 5, Jour = DateTime.ParseExact("2019-02-25", "yyyy-MM-dd", ci), IdClient = 5, NbPersonnes = 1, HeureArrivee = 15 }, //Child entity (empty key) new Reservation() { NumChambre = 10, Jour = DateTime.ParseExact("2019-01-25", "yyyy-MM-dd", ci), IdClient = 15, NbPersonnes = 3, HeureArrivee = 6 }, //Child entity (empty key) new Reservation() { NumChambre = 20, Jour = DateTime.ParseExact("2019-02-03", "yyyy-MM-dd", ci), IdClient = 65, NbPersonnes = 2, HeureArrivee = 7 }, //Child entity (empty key) new Reservation() { NumChambre = 15, Jour = DateTime.ParseExact("2019-03-05", "yyyy-MM-dd", ci), IdClient = 12, NbPersonnes = 3, HeureArrivee = 10 }, //Child entity (empty key) new Reservation() { NumChambre = 5, Jour = DateTime.ParseExact("2019-02-16", "yyyy-MM-dd", ci), IdClient = 56, NbPersonnes = 3, HeureArrivee = 17 }, //Child entity (empty key) new Reservation() { NumChambre = 5, Jour = DateTime.ParseExact("2019-04-18", "yyyy-MM-dd", ci), IdClient = 35, NbPersonnes = 2, HeureArrivee = 15 }, //Child entity (empty key) new Reservation() { NumChambre = 5, Jour = DateTime.ParseExact("2019-03-19", "yyyy-MM-dd", ci), IdClient = 13, NbPersonnes = 1, HeureArrivee = 13 }, //Child entity (empty key) new Reservation() { NumChambre = 5, Jour = DateTime.ParseExact("2019-02-20", "yyyy-MM-dd", ci), IdClient = 14, NbPersonnes = 1, HeureArrivee = 6 }, }; foreach (var data in reserv) { db.Reservation.Add(data); db.SaveChanges(); } }
public bool SupprimerTelephhone(string telephone) { bool done = false; try { var Telephone = grandhotel.Telephone.Where(x => x.Numero == telephone).FirstOrDefault(); grandhotel.Telephone.Remove(Telephone); grandhotel.SaveChanges(); done = true; } catch (Exception ex) { } return(done); }
public void SaveLogoutToken(LogoutToken token) { db.LogoutToken.Add(token); db.SaveChanges(); }
public void CreateClient(Client client) { db.Client.Add(client); db.SaveChanges(); }