Пример #1
0
 public int GetCount()
 {
     using (YesAlaMungoEntities context = DbContextFactory.Create())
     {
         return(context.Set <T>().Count());
     }
 }
Пример #2
0
        public UsedBook SearchBook(Sell sell)
        {
            using (YesAlaMungoEntities context = new YesAlaMungoEntities())
            {
                var query = from x in context.SellUsedBooks
                            where x.SellID.Equals(sell.SellID)
                            select new
                {
                    UsedBook  = x.UsedBook,
                    Title     = x.UsedBook.MetaDataBook.Title,
                    Writer    = x.UsedBook.MetaDataBook.Writer,
                    Publisher = x.UsedBook.MetaDataBook.Publisher,
                    Price     = x.UsedBook.MetaDataBook.Price,
                    ImagePath = x.UsedBook.MetaDataBook.Image
                };

                var list = query.ToList();

                foreach (var item in list)
                {
                    item.UsedBook.Title     = item.Title;
                    item.UsedBook.Writer    = item.Writer;
                    item.UsedBook.Publisher = item.Publisher;
                    item.UsedBook.Price     = item.Price;
                    item.UsedBook.ImagePath = item.ImagePath;
                }

                return(list.ConvertAll(x => x.UsedBook).FirstOrDefault());
            }
        }
        public List <MetaDataBook> Search(string eTitle, string eWriter, string ePublisher)
        {
            using (YesAlaMungoEntities context = new YesAlaMungoEntities())
            {
                var query = from x in context.MetaDataBooks
                            select x;

                if (string.IsNullOrEmpty(eTitle) == false)
                {
                    query = query.Where(x => x.Title.Contains(eTitle));
                }
                if (string.IsNullOrEmpty(eWriter) == false)
                {
                    query = query.Where(x => x.Writer.Contains(eWriter));
                }
                if (string.IsNullOrEmpty(ePublisher) == false)
                {
                    query = query.Where(x => x.Publisher.Contains(ePublisher));
                }

                List <MetaDataBook> books = query.ToList();

                return(books);
            }
        }
Пример #4
0
 public List <T> GetAll()
 {
     using (YesAlaMungoEntities context = DbContextFactory.Create())
     {
         // DbSet의 제약조건과 일치해야 한다.
         return(context.Set <T>().ToList());
     }
 }
Пример #5
0
 public void Delete(T entity)
 {
     using (YesAlaMungoEntities context = DbContextFactory.Create())
     {
         context.Entry(entity).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Пример #6
0
 public void Insert(T entity)
 {
     using (YesAlaMungoEntities context = DbContextFactory.Create())
     {
         context.Set <T>().Add(entity);
         context.SaveChanges();
     }
 }
        public static YesAlaMungoEntities Create()
        {
            YesAlaMungoEntities context = new YesAlaMungoEntities();

            context.Database.Log = Write;

            return(context);
        }
Пример #8
0
        public List <Buy> Search2(string bookName, string cusID, DateTime?fromDate, DateTime?toDate)
        {
            using (YesAlaMungoEntities context = DbContextFactory.Create())
            {
                //var query = from x in context.Buys
                //            join y in context.UsedBooks on x.BuyID equals y.UsedBookID
                //            //join z in context.Customers on x.BuyerID equals z.CustomerID
                //            select new
                //            {
                //                Buy = x,
                //                BookTitle = y.MetaDataBook.Title,
                //                //BuyerLoginID = z.LoginID
                //                BuyerLoginID = x.Customer.LoginID
                //            };

                var query = from x in context.BuyUsedBooks
                            // where x.Buy.BuyerID.Equals(cusID)
                            orderby x.BuyID
                            select new
                {
                    BuyUsedBook = x,
                    BookTitle   = x.UsedBook.MetaDataBook.Title,
                    //BuyerLoginID = z.LoginID
                    BuyerLoginID = x.Buy.Customer.LoginID,
                };

                if (string.IsNullOrEmpty(bookName) == false)
                {
                    query = query.Where(y => y.BookTitle.Contains(bookName));
                }

                if (string.IsNullOrEmpty(cusID) == false)
                {
                    query = query.Where(x => x.BuyUsedBook.Buy.BuyerLoginID.Contains(cusID));
                }


                if (fromDate.HasValue && toDate.HasValue)
                {
                    query = query.Where(x => x.BuyUsedBook.Buy.OrderDate >= fromDate && x.BuyUsedBook.Buy.OrderDate <= toDate);
                }

                var list = query.ToList();

                foreach (var item in list)
                {
                    item.BuyUsedBook.Buy.Title        = item.BookTitle;
                    item.BuyUsedBook.Buy.BuyerLoginID = item.BuyerLoginID;
                }


                return(list.ConvertAll(x => x.BuyUsedBook.Buy));
            }
        }
Пример #9
0
        public bool Check(string id, string pw)
        {
            using (YesAlaMungoEntities context = new YesAlaMungoEntities())
            {
                var query = from x in context.Employees
                            where x.LoginID.Equals(id) && x.PassWord.Equals(pw)
                            select x;

                return(query.Any());
            }
        }
        public bool CheckId(string id)
        {
            using (YesAlaMungoEntities context = new YesAlaMungoEntities())
            {
                var query = from x in context.Customers
                            where x.LoginID.Equals(id)
                            select x;

                return(query.Any());
            }
        }
        public List <Customer> CheckUser(string id, string pw)
        {
            using (YesAlaMungoEntities context = new YesAlaMungoEntities())
            {
                var query = from x in context.Customers
                            where x.LoginID.Equals(id) && x.PassWord.Equals(pw)
                            select x;

                return(query.ToList());
            }
        }
Пример #12
0
        public List <Sell> Search(string sellerId, bool?bookChecked)
        {
            using (YesAlaMungoEntities context = new YesAlaMungoEntities())
            {
                //var query = from x in context.Sells
                //            join y in context.Customers on x.SellID equals y.CustomerID
                //var query = from x in context.Sells
                //    join y in context.UsedBooks on x.SellID equals y.UsedBookID
                //    join z in context.Customers on x.SellID equals z.CustomerID
                //    select new
                //    {
                //        Sells = x,
                //        Customer =z,
                //        LoginID = z.LoginID,
                //        Title = y.MetaDataBook.Title,
                //        Quality = y.Quality,
                //        Price =  y.MetaDataBook.Price
                //    };

                var query = from x in context.SellUsedBooks
                            select new
                {
                    Sells    = x.Sell,
                    Customer = x.Sell.Customer,
                    LoginID  = x.Sell.Customer.LoginID,
                    Title    = x.UsedBook.MetaDataBook.Title,
                    Quality  = x.UsedBook.Quality,
                    Price    = x.UsedBook.MetaDataBook.Price
                };

                if (string.IsNullOrEmpty(sellerId) == false)
                {
                    query = query.Where(x => x.Customer.LoginID.Equals(sellerId));
                }

                if (bookChecked != null)
                {
                    query = query.Where(x => x.Sells.Checked == bookChecked);
                }

                var list = query.ToList();

                foreach (var item in list)
                {
                    item.Sells.Title   = item.Title;
                    item.Sells.Quality = item.Quality;
                    item.Sells.Price   = item.Price;
                    item.Sells.LoginID = item.LoginID;
                }

                return(list.ConvertAll(x => x.Sells));
            }
        }
        public Customer Check(string id, string pw)
        {
            using (YesAlaMungoEntities context = new YesAlaMungoEntities())
            {
                var query = from x in context.Customers
                            where x.LoginID.Equals(id) && x.PassWord.Equals(pw)
                            select x;
                var list = query.ToList();


                return(list.FirstOrDefault());
            }
        }
Пример #14
0
        public List <Buy> Search3(string cusID, string bookName)
        {
            using (YesAlaMungoEntities context = DbContextFactory.Create())
            {
                var query = from x in context.BuyUsedBooks
                            orderby x.BuyID
                            select new
                {
                    BuyUsedBoos   = x,
                    Buy           = x.Buy,
                    UsedBook      = x.UsedBook,
                    BuyerLoginID  = x.Buy.Customer.LoginID,
                    BookTitle     = x.UsedBook.MetaDataBook.Title,
                    BookWriter    = x.UsedBook.MetaDataBook.Writer,
                    BookPublisher = x.UsedBook.MetaDataBook.Publisher,
                    BookQuality   = x.UsedBook.Quality,
                    BookPricce    = x.UsedBook.MetaDataBook.Price,
                    ImagePath     = x.UsedBook.MetaDataBook.Image
                };

                if (string.IsNullOrEmpty(bookName) == false)
                {
                    query = query.Where(y => y.BookTitle.Contains(bookName));
                }

                if (string.IsNullOrEmpty(cusID) == false)
                {
                    query = query.Where(x => x.BuyerLoginID.Contains(cusID));
                }

                query = query.Where(x => x.Buy.InvoiceState == 0);

                var list = query.ToList();

                foreach (var item in list)
                {
                    item.Buy.Title        = item.BookTitle;
                    item.Buy.BuyerLoginID = item.BuyerLoginID;
                    item.Buy.Writer       = item.BookWriter;
                    item.Buy.Pubilsher    = item.BookPublisher;
                    item.Buy.Quality      = item.BookQuality;
                    item.Buy.ImagePath    = item.ImagePath;

                    item.Buy.Price = Discount.SalePrices(item.BookQuality, item.BookPricce);
                }


                return(list.ConvertAll(x => x.Buy));
            }
        }
        public Employee Check(string id, string pw)
        {
            using (YesAlaMungoEntities context = new YesAlaMungoEntities())
            {
                var query = from x in context.Employees
                            where x.LoginID.Equals(id) && x.PassWord.Equals(pw)
                            select x;

                var list = query.ToList();

                if (list.Count() != 0)
                {
                    return(list[0]);
                }
                else
                {
                    return(null);
                }
            }
        }
Пример #16
0
        public List <Buy> Search(string cusId,
                                 string title, DateTime?fromDate, DateTime?ToDate)
        {
            using (YesAlaMungoEntities context = new YesAlaMungoEntities())
            {
                /*
                 * 구매버튼을 눌렀을 경우
                 * 구매 동시에                *
                 */
                //var query = from x in context.Buys
                //    where x.UsedBooks
                //    select x;

                //var productsInCategory = db.Categorys
                //    .Where(c => c.CategoryId == categoryId)
                //    .SelectMany(c => c.Products);


                //var products = (from p in db.Product_Category
                //    join ProductTable pt on p.ID = pt.ProductID
                //join Category c on c.ID = P.CategoryID
                //select new
                //{
                //    p.ID,
                //    p.Name,
                //    p.Description,
                //    p.Price
                //}).ToList();



                //buy 에서 title 과 customerId만 빼오면되는데.


                //var query = from x in context.Buys
                //            join y in context.UsedBooks on x.BuyID equals y.UsedBookID
                //            where x.Customer.LoginID.Equals(cusId)
                //            select new
                //            {
                //                Buy = x,
                //                BuyerLoginID = x.Customer.LoginID,
                //                Title = y.MetaDataBook.Title,
                //                BookWriter = y.MetaDataBook.Writer
                //            };


                var query = from x in context.BuyUsedBooks
                            where x.Buy.Customer.LoginID.Equals(cusId)
                            orderby x.Buy.BuyID
                            select new
                {
                    Buy          = x,
                    BuyerLoginID = x.Buy.Customer.LoginID,
                    Title        = x.UsedBook.MetaDataBook.Title,
                    BookWriter   = x.UsedBook.MetaDataBook.Writer
                };

                if (string.IsNullOrEmpty(title) == false)
                {
                    query = query.Where(x => x.Title.Contains(title));
                }

                if (fromDate != null && ToDate != null)
                {
                    query = query.Where(x => x.Buy.Buy.OrderDate >=
                                        fromDate && x.Buy.Buy.OrderDate <= ToDate);
                }



                var list = query.ToList();

                foreach (var item in list)
                {
                    item.Buy.Buy.Title        = item.Title;
                    item.Buy.Buy.BuyerLoginID = item.BuyerLoginID;
                    item.Buy.Buy.Writer       = item.BookWriter;
                }



                //var list =context.UsedBooks.SelectMany (x => x.Buys);
                // list.Where(x=>x.)

                // var query = from VAR in


                return(list.ConvertAll(x => x.Buy.Buy));
            }
        }
Пример #17
0
        public List <Buy> Search(string cusId,
                                 string title, DateTime?fromDate, DateTime?ToDate)
        {
            using (YesAlaMungoEntities context = new YesAlaMungoEntities())
            {
                /*
                 * 구매버튼을 눌렀을 경우
                 * 구매 동시에                *
                 */
                //var query = from x in context.Buys
                //    where x.UsedBooks
                //    select x;

                //var productsInCategory = db.Categorys
                //    .Where(c => c.CategoryId == categoryId)
                //    .SelectMany(c => c.Products);


                //var products = (from p in db.Product_Category
                //    join ProductTable pt on p.ID = pt.ProductID
                //join Category c on c.ID = P.CategoryID
                //select new
                //{
                //    p.ID,
                //    p.Name,
                //    p.Description,
                //    p.Price
                //}).ToList();



                //buy 에서 title 과 customerId만 빼오면되는데.

                string tempId = "admin";
                var    query  = from x in context.Buys
                                join y in context.UsedBooks on x.BuyID equals y.UsedBookID
                                where x.Customer.LoginID.Equals(tempId)
                                select new
                {
                    Buy   = x,
                    Title = y.MetaDataBook.Title
                };

                var list = query.ToList();

                foreach (var item in list)
                {
                    item.Buy.Title = item.Title;
                }



                //var list =context.UsedBooks.SelectMany (x => x.Buys);
                // list.Where(x=>x.)

                // var query = from VAR in


                return(list.ConvertAll(x => x.Buy));
            }
        }
Пример #18
0
        public List <UsedBook> Search(string title, string writer, string quality)
        {
            using (YesAlaMungoEntities context = DbContextFactory.Create())
            {
                var query = from x in context.UsedBooks
                            where x.IsSell == false
                            select new
                {
                    UsedBook      = x,
                    BookTitle     = x.MetaDataBook.Title,
                    BookWriter    = x.MetaDataBook.Writer,
                    BookPrice     = x.MetaDataBook.Price,
                    ImagePath     = x.MetaDataBook.Image,
                    BookPublisher = x.MetaDataBook.Publisher
                };

                if (string.IsNullOrEmpty(title) == false)
                {
                    query = query.Where(x => x.UsedBook.MetaDataBook.Title.Contains(title));
                }

                if (string.IsNullOrEmpty(writer) == false)
                {
                    query = query.Where(x => x.UsedBook.MetaDataBook.Writer.Contains(writer));
                }

                if (string.IsNullOrEmpty(quality) == false)
                {
                    query = query.Where(x => x.UsedBook.Quality.Contains(quality));
                }



                var list = query.ToList();

                foreach (var item in list)
                {
                    item.UsedBook.Title     = item.BookTitle;
                    item.UsedBook.Writer    = item.BookWriter;
                    item.UsedBook.ImagePath = item.ImagePath;
                    item.UsedBook.Publisher = item.BookPublisher;

                    if (item.UsedBook.Quality == "A")
                    {
                        item.UsedBook.Price = (int)(item.BookPrice * 0.9);
                    }
                    else if (item.UsedBook.Quality == "B")
                    {
                        item.UsedBook.Price = (int)(item.BookPrice * 0.8);
                    }
                    else if (item.UsedBook.Quality == "C")
                    {
                        item.UsedBook.Price = (int)(item.BookPrice * 0.7);
                    }
                    else if (item.UsedBook.Quality == "F")
                    {
                        item.UsedBook.Price = (int)(item.BookPrice * 0.5);
                    }
                }

                return(list.ConvertAll(x => x.UsedBook));
            }
        }