コード例 #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
ファイル: CarRepository.cs プロジェクト: 15831944/Projects-1
 protected override Car UpdateEntity(CarRentalContext entityContext, Car entity)
 {
     return((from e in entityContext.CarSet
             where e.CarId == entity.CarId
             select e).FirstOrDefault());
 }