Пример #1
0
 public IEnumerable <Rental> GetCurrentlyRentedCars()
 {
     using (var context = new CarRentalContext())
     {
         return(context.RentalSet
                .Where(e => e.DateRented == null)
                .ToList());
     }
 }
Пример #2
0
 public IEnumerable <Rental> GetRentalHistoryByCar(int carId)
 {
     using (var context = new CarRentalContext())
     {
         return(context.RentalSet
                .Where(e => e.CarId == carId)
                .ToList());
     }
 }
Пример #3
0
 public Account GetByLogin(string login)
 {
     using (CarRentalContext entityContext = new CarRentalContext())
     {
         return((from a in entityContext.AccountSet
                 where a.LoginEmail == login
                 select a).FirstOrDefault());
     }
 }
Пример #4
0
 public Rental[] GetRentalHistoryByAccount(int accountId)
 {
     using (var context = new CarRentalContext())
     {
         return(context.RentalSet
                .Where(e => e.AccountId == accountId)
                .ToArray());
     }
 }
 public IEnumerable <Reservation> GetReservationsByPickupDate(DateTime pickupDate)
 {
     using (var context = new CarRentalContext())
     {
         return(context.ReservationSet
                .Where(e => e.RentalDate < pickupDate)
                .ToList());
     }
 }
Пример #6
0
        public IEnumerable <Rental> GetCurrentlyRentedCars()
        {
            using (CarRentalContext entityContext = new CarRentalContext()) {
                var query = from r in entityContext.RentalSet
                            where r.DateReturned == null
                            select r;

                return(query.ToFullyLoaded());
            }
        }
Пример #7
0
        public Rental GetCurrentRentalByCar(int carId)
        {
            using (CarRentalContext entityContext = new CarRentalContext()) {
                var query = from r in entityContext.RentalSet
                            where r.CarId == carId && r.DateReturned == null
                            select r;

                return(query.FirstOrDefault());
            }
        }
Пример #8
0
        public IEnumerable <Rental> GetRentalHistoryByCar(int carId)
        {
            using (CarRentalContext entityContext = new CarRentalContext()) {
                var query = from r in entityContext.RentalSet
                            where r.CarId == carId
                            select r;

                return(query.ToFullyLoaded());
            }
        }
Пример #9
0
        public IEnumerable <Rental> GetRentalHistoryByAccount(int accountId)
        {
            using (CarRentalContext entityContext = new CarRentalContext()) {
                var query = from e in entityContext.RentalSet
                            where e.AccountId == accountId
                            select e;

                return(query.ToFullyLoaded());
            }
        }
Пример #10
0
        public IEnumerable <Reservation> GetReservationsByPickupDate(DateTime pickupDate)
        {
            using (CarRentalContext entityContext = new CarRentalContext()) {
                var query = from r in entityContext.ReservationSet
                            where r.RentalDate < pickupDate
                            select r;

                return(query.ToFullyLoaded());
            }
        }
Пример #11
0
        protected override Rental GetEntity(CarRentalContext entityContext, int id)
        {
            var query = (from e in entityContext.RentalSet
                         where e.RentalId == id
                         select e);

            var results = query.FirstOrDefault();

            return(results);
        }
Пример #12
0
        protected override Rental GetEntity(CarRentalContext entityContext, object id)
        {
            int idToFind = (int)id;

            var query = from e in entityContext.RentalSet
                        where e.RentalId == idToFind
                        select e;

            var result = query.FirstOrDefault();

            return(result);
        }
Пример #13
0
        protected override Account GetEntity(CarRentalContext entityContext, object id)
        {
            int idToGet = (int)id;

            var query = from e in entityContext.AccountSet
                        where e.AccountId == idToGet
                        select e;

            var result = query.FirstOrDefault();

            return(result);
        }
 public IEnumerable <CustomerReservationInfo> GetCurrentCustomerReservationInfo()
 {
     using (var context = new CarRentalContext())
     {
         return(context.ReservationSet
                .Join(context.AccountSet, r => r.AccountId, a => a.AccountId, (r, a) => new { r, a })
                .Join(context.CarSet, ra => ra.r.CarId, c => c.CarId, (ra, c) => new CustomerReservationInfo
         {
             Customer = ra.a,
             Reservation = ra.r,
             Car = c
         })
                .ToList());
     }
 }
Пример #15
0
        public IEnumerable <Contracts.CustomerReservationInfo> GetCurrentCustomerReservationInfo()
        {
            using (CarRentalContext entityContext = new CarRentalContext()) {
                var query = from r in entityContext.ReservationSet
                            join a in entityContext.AccountSet on r.AccountId equals a.AccountId
                            join c in entityContext.CarSet on r.CarId equals c.CarId
                            select new CustomerReservationInfo()
                {
                    Customer    = a,
                    Car         = c,
                    Reservation = r
                };

                return(query.ToFullyLoaded());
            }
        }
Пример #16
0
        public IEnumerable <CustomerRentalInfo> GetCurrentCustomerRentalInfo()
        {
            using (CarRentalContext entityContext = new CarRentalContext()) {
                var query = from r in entityContext.RentalSet
                            where r.DateReturned == null
                            join a in entityContext.AccountSet on r.AccountId equals a.AccountId
                            join c in entityContext.CarSet on r.CarId equals c.CarId
                            select new CustomerRentalInfo()
                {
                    Customer = a,
                    Car      = c,
                    Rental   = r
                };

                return(query.ToFullyLoaded());
            }
        }
Пример #17
0
 protected override Account UpdateEntity(CarRentalContext entityContext, Account entity)
 {
     return((from e in entityContext.AccountSet
             where e.AccountId == entity.AccountId
             select e).FirstOrDefault());
 }
Пример #18
0
 protected override Account AddEntity(CarRentalContext entityContext, Account entity)
 {
     return(entityContext.AccountSet.Add(entity));
 }
 protected override Car UpdateEntity(CarRentalContext entityContext, Car entity)
 {
     return(entityContext.CarSet
            .FirstOrDefault(e => e.CarId == entity.CarId));
 }
 protected override Car GetEntity(CarRentalContext entityContext, int id)
 {
     return(entityContext.CarSet.Find(id));
 }
 protected override IEnumerable <Car> GetEntities(CarRentalContext entityContext)
 {
     return(entityContext.CarSet.ToList());
 }
 protected override Car AddEntity(CarRentalContext entityContext, Car entity)
 {
     return(entityContext.CarSet.Add(entity));
 }
Пример #23
0
 public Repository(CarRentalContext ctx)
 {
     context = ctx;
     context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
 }
Пример #24
0
 protected override Account UpdateEntity(CarRentalContext entityContext, Account entity)
 {
     return(entityContext.AccountSet
            .FirstOrDefault(e => e.AccountId == entity.AccountId));
 }
Пример #25
0
 protected override Rental UpdateEntity(CarRentalContext entityContext, Rental entity)
 {
     return(entityContext.RentalSet
            .FirstOrDefault(e => e.RentalId == entity.RentalId));
 }
Пример #26
0
 protected override Rental AddEntity(CarRentalContext entityContext, Rental entity)
 {
     return(entityContext.RentalSet.Add(entity));
 }
Пример #27
0
 public EditModel(CarRental.Data.CarRentalContext context)
 {
     _context = context;
 }
Пример #28
0
 protected override IEnumerable <Account> GetEntities(CarRentalContext entityContext)
 {
     return(from e in entityContext.AccountSet
            select e);
 }
Пример #29
0
 protected override Rental UpdateEntity(CarRentalContext entityContext, Rental entity)
 {
     return((from e in entityContext.RentalSet
             where e.RentalId == entity.RentalId
             select e).FirstOrDefault());
 }
Пример #30
0
 protected override Car UpdateEntity(CarRentalContext entityContext, Car entity)
 {
     return((from e in entityContext.CarSet
             where e.CarId == entity.CarId
             select e).FirstOrDefault());
 }