Example #1
0
        public void Insert(T entity)
        {
            PCBangEntities context = CreateContext();

            context.Entry(entity).State = EntityState.Added;
            context.SaveChanges();
        }
Example #2
0
        public void Update(T entity)
        {
            PCBangEntities context = CreateContext();

            context.Entry(entity).State = EntityState.Modified;
            context.SaveChanges();
        }
Example #3
0
        public void Delete(T entity)
        {
            PCBangEntities context = CreateContext();

            context.Entry(entity).State = EntityState.Deleted;
            context.SaveChanges();
        }
Example #4
0
        public List <Game> TopFiveGame()
        {
            PCBangEntities context = CreateContext();
            List <Game>    games   = GetAll();

            return(games.OrderByDescending(x => x.PlayCount).ToList());
        }
Example #5
0
        protected PCBangEntities CreateContext()
        {
            PCBangEntities context = new PCBangEntities();

            context.Configuration.ProxyCreationEnabled = false;
            return(context);
        }
Example #6
0
        public int?GetByName(string name)
        {
            PCBangEntities context = CreateContext();
            var            query   = from x in context.Products
                                     where x.Name == name
                                     select x.ProductID;

            return(query.FirstOrDefault());
        }
Example #7
0
        public int CheckItem(Order order)
        {
            PCBangEntities context = CreateContext();
            var            query   = from x in context.Orders
                                     where x.OrderID == order.OrderID
                                     select x.Product.CodeID;

            return(query.ToList()[0]);
        }
Example #8
0
        public List <Game> GetbyGenre(int codeId)
        {
            PCBangEntities context = CreateContext();
            var            query   = from x in context.GameGenres
                                     where x.CodeID == codeId
                                     select x.Game;

            return(query.ToList());
        }
Example #9
0
        public void Update(List <T> entities)
        {
            PCBangEntities context = CreateContext();

            context.Entry(entities).State = EntityState.Modified;

/*            foreach (var entity in entities)
 *              context.Entry(entity).State = EntityState.Modified;*/
            context.SaveChanges();
        }
Example #10
0
        public List <Chatting> GetNotRead(bool sent, int seatId)
        {
            PCBangEntities context = CreateContext();

            var query = from x in context.Chattings
                        where x.SeatID == seatId
                        select x;

            return(query.ToList());
        }
Example #11
0
        public List <Seat> GetCanUse()
        {
            PCBangEntities context = CreateContext();

            var query = from x in context.Seats
                        where x.CustomerID == null && x.Breakdown == false
                        select x;

            return(query.ToList());
        }
Example #12
0
        public List <Chatting> GetNotRead(bool sent)
        {
            PCBangEntities context = CreateContext();

            var query = from x in context.Chattings
                        where x.Sent == sent && x.Checked == false
                        select x;

            return(query.ToList());
        }
Example #13
0
        public List <Seat> GetUsing()
        {
            PCBangEntities context = CreateContext();

            var query = from x in context.Seats
                        where x.CustomerID != null
                        select x;

            return(query.ToList());
        }
Example #14
0
        public List <Product> Getbycode(int codeId)
        {
            PCBangEntities context = CreateContext();

            var query = from x in context.Products
                        where x.CodeID == codeId
                        select x;

            //select new { album = x, artistname = x.artist.name };
            return(query.ToList());
        }
Example #15
0
        public void DeleteAll(bool sent, int seatId)
        {
            PCBangEntities context = CreateContext();

            var query = from x in context.Chattings
                        where x.SeatID == seatId
                        select x;
            var chattings = query.ToList();

            foreach (var chatting in chattings)
            {
                Delete(chatting);
            }
        }
Example #16
0
        public void DeleteAll(bool sent)
        {
            PCBangEntities context = CreateContext();

            var query = from x in context.Chattings
                        where x.Sent == sent && x.Checked == false
                        select x;
            var chattings = query.ToList();

            foreach (var chatting in chattings)
            {
                Update(chatting);
            }
        }
Example #17
0
        public List <Seat> GetWithCustomer()
        {
            PCBangEntities context = CreateContext();
            var            query   = from x in context.Seats
                                     select new { Seat = x, CustomerName = x.Customer.Name, RemainingTime = x.Customer == null ? 0:x.Customer.RemainingTime };
            var list = query.ToList();

            foreach (var x in list)
            {
                x.Seat.RemainingTime = x.RemainingTime;
                x.Seat.CustomerName  = x.CustomerName;
            }

            return(list.ConvertAll(x => x.Seat));
        }
Example #18
0
        public void UpdateAll(bool sent, int seatId)
        {
            PCBangEntities context = CreateContext();

            var query = from x in context.Chattings
                        where x.Sent == sent && x.Checked == false && x.SeatID == seatId
                        select x;
            var chattings = query.ToList();

            foreach (var chatting in chattings)
            {
                chatting.Checked = true;
                Update(chatting);
            }
        }
Example #19
0
        public List <Order> GetWithProduct(bool buyed, int customerId)
        {
            PCBangEntities context = CreateContext();
            var            query   = from x in context.Orders
                                     where x.buyed == buyed && x.CustomerID == customerId
                                     select new { Order = x, ProductName = x.Product.Name, ProductPrice = x.Product.Price };
            var list = query.ToList();

            foreach (var x in list)
            {
                x.Order.ProductName  = x.ProductName;
                x.Order.ProductPrice = x.ProductPrice;
            }

            return(list.ConvertAll(x => x.Order));
        }
Example #20
0
        public int GetTotalPrice(bool buyed, int customerId)
        {
            PCBangEntities context = CreateContext();
            var            query   = from x in context.Orders
                                     where x.buyed == buyed && x.CustomerID == customerId
                                     select x.Product.Price;
            var list = query.ToList();
            int sum  = 0;

            foreach (var x in list)
            {
                sum += x;
            }

            return(sum);
        }
Example #21
0
        public void DeleteOrder(int customerId)
        {
            PCBangEntities context = CreateContext();

            var query = from x in context.Orders
                        where x.buyed == false && x.CustomerID == customerId
                        select x;

            List <Order> orders = query.ToList();

            if (orders != null)
            {
                foreach (var order in orders)
                {
                    Delete(order);
                }
            }
        }
Example #22
0
        public Customer Login(string loginId, string password)
        {
            PCBangEntities context  = CreateContext();
            Customer       customer = context.Customers.FirstOrDefault(a => a.LoginID == loginId);

            if (customer == null)
            {
                return(null);
            }
            else
            {
                if (customer.LoginPassword == password)
                {
                    return(customer);
                }
                else
                {
                    return(null);
                }
            }
        }
Example #23
0
        public Code Get(int codeId)
        {
            PCBangEntities context = CreateContext();

            return(context.Codes.FirstOrDefault(a => a.CodeID == codeId));
        }
Example #24
0
        public Customer Get(int customerId)
        {
            PCBangEntities context = CreateContext();

            return(context.Customers.FirstOrDefault(a => a.CustomerID == customerId));
        }
Example #25
0
        public int GetCount()
        {
            PCBangEntities context = CreateContext();

            return(context.Set <T>().Count());
        }
Example #26
0
        public List <T> GetAll()
        {
            PCBangEntities context = CreateContext();

            return(context.Set <T>().ToList());
        }
Example #27
0
        public bool CanUseId(string loginId)
        {
            PCBangEntities context = CreateContext();

            return(context.Customers.FirstOrDefault(a => a.LoginID == loginId) == null ? true : false);
        }
Example #28
0
        public bool LoginCheck(int customerId)
        {
            PCBangEntities context = CreateContext();

            return(context.Seats.FirstOrDefault(a => a.CustomerID == customerId) == null ? false : true);
        }
Example #29
0
        public GameGenre Get(int gameId, int codeId)
        {
            PCBangEntities context = CreateContext();

            return(context.GameGenres.FirstOrDefault(a => a.GameID == gameId && a.CodeID == codeId));
        }
Example #30
0
        public Seat Get(int seatId)
        {
            PCBangEntities context = CreateContext();

            return(context.Seats.FirstOrDefault(a => a.SeatID == seatId));
        }