Esempio n. 1
0
        public void Insert(T entity)
        {
            PCBangEntities context = CreateContext();

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

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

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

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

            context.Configuration.ProxyCreationEnabled = false;
            return(context);
        }
Esempio n. 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());
        }
Esempio n. 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]);
        }
Esempio n. 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());
        }
Esempio n. 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();
        }
Esempio n. 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());
        }
Esempio n. 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());
        }
Esempio n. 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());
        }
Esempio n. 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());
        }
Esempio n. 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());
        }
Esempio n. 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);
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 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));
        }
Esempio n. 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);
            }
        }
Esempio n. 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));
        }
Esempio n. 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);
        }
Esempio n. 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);
                }
            }
        }
Esempio n. 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);
                }
            }
        }
Esempio n. 23
0
        public Code Get(int codeId)
        {
            PCBangEntities context = CreateContext();

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

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

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

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

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

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

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

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