Ejemplo n.º 1
0
        public void BookCar(int Id, string startDate, string endDate)
        {
            Car Car = _context.Cars
                      .Where(p => p.Id == Id)
                      .Include(p => p.Reservations)
                      .SingleOrDefault();

            var reservation = new Reservation
            {
                startDate = DateTime.Parse(startDate),
                endDate   = DateTime.Parse(endDate),
                Car       = Car,
                userEmail = GetUserEmail(GetUserId())
            };

            Car.Reservations.Add(reservation);
            _context.Reservations.Update(reservation);
            _context.SaveChanges();
        }
Ejemplo n.º 2
0
 public virtual void Commit()
 {
     _context.SaveChanges();
 }