コード例 #1
0
 public static List <CreditCard> GetCreditCard(int userid)
 {
     using (Bookshop entities = new Bookshop())
     {
         List <CreditCard> creditcardlist = entities.CreditCards.Where(c => c.UserID == userid).ToList <CreditCard>();
         return(creditcardlist);
     }
 }
コード例 #2
0
 public static void AddCardInfo(int userid, string cardholdername, string cardno, int expmonth, int expyear, int cvc_code)
 {
     using (Bookshop entities = new Bookshop())
     {
         CreditCard creditCard = new CreditCard()
         {
             CardID         = entities.CreditCards.Count() > 0 ? entities.CreditCards.Max(c => c.CardID) + 1 : 1,
             UserID         = userid,
             FullName       = cardholdername,
             CardNumber     = cardno,
             ExpiryMonth    = expmonth,
             ExpiryYear     = expyear,
             SecurityNumber = cvc_code
         };
         entities.CreditCards.Add(creditCard);
         entities.SaveChanges();
     }
 }
コード例 #3
0
        public static IQueryable <BookList> GetBooklists(string searchquery)
        {
            var entities = new Bookshop();

            var categoryname = entities.Categories.Where(x => x.Name.Contains(searchquery)).SingleOrDefault();

            // IQueryable<BookList> booklist = entities.Books.Where(b => b.Author == author || b.Title == title || b.CategoryID == category);
            if (categoryname != null)
            {
                IQueryable <BookList> booklist = from a in entities.Books.Where(a => a.Author.Contains(searchquery) || a.Title.Contains(searchquery) || a.ISBN.Contains(searchquery) || a.CategoryID == categoryname.CategoryID)
                                                 from b in entities.Categories
                                                 where a.CategoryID == b.CategoryID
                                                 select new BookList
                {
                    BookID       = a.BookID,
                    Author       = a.Author,
                    CategoryID   = a.CategoryID,
                    CategoryName = b.Name,
                    Title        = a.Title,
                    ISBN         = a.ISBN,
                    Price        = a.Price,
                    Stock        = a.Stock
                };
                return(booklist);
            }
            else
            {
                IQueryable <BookList> booklist = from a in entities.Books.Where(a => a.Author.Contains(searchquery) || a.Title.Contains(searchquery) || a.ISBN.Contains(searchquery))
                                                 from b in entities.Categories
                                                 where a.CategoryID == b.CategoryID
                                                 select new BookList
                {
                    BookID       = a.BookID,
                    Author       = a.Author,
                    CategoryID   = a.CategoryID,
                    CategoryName = b.Name,
                    Title        = a.Title,
                    ISBN         = a.ISBN,
                    Price        = a.Price,
                    Stock        = a.Stock
                };
                return(booklist);
            }
        }
コード例 #4
0
        public static IQueryable <BookList> GetBooklistAll()
        {
            var entities = new Bookshop();
            //IQueryable<Book> booklist = entities.Books;
            IQueryable <BookList> booklist = from a in entities.Books
                                             from b in entities.Categories
                                             where a.CategoryID == b.CategoryID
                                             select new BookList
            {
                BookID       = a.BookID,
                Author       = a.Author,
                CategoryID   = a.CategoryID,
                CategoryName = b.Name,
                Title        = a.Title,
                ISBN         = a.ISBN,
                Price        = a.Price,
                Stock        = a.Stock
            };

            return(booklist);
        }