Esempio n. 1
0
 public int Count()
 {
     using (EShopDB db = new EShopDB())
     {
         int count = db.BookType.Count();
         return(count);
     }
 }
Esempio n. 2
0
 public bool InsertSaleDetail(SaleDetail detail)
 {
     using (EShopDB db = new EShopDB())
     {
         db.SaleDetail.Add(detail);
         bool isSuccess = db.SaveChanges() > 0;
         return(isSuccess);
     }
 }
Esempio n. 3
0
 public bool InsertCartInfo(ShoppingCart cInfo)
 {
     using (EShopDB db = new EShopDB())
     {
         db.ShoppingCart.Add(cInfo);
         bool isSuccess = db.SaveChanges() > 0;
         return(isSuccess);
     }
 }
Esempio n. 4
0
 public bool InsertOtherType(OtherType otherType)
 {
     using (EShopDB db = new EShopDB())
     {
         db.OtherType.Add(otherType);
         bool isSuccess = db.SaveChanges() > 0;
         return(isSuccess);
     }
 }
Esempio n. 5
0
 public bool InsertBookInfo(BookInfo bookInfo)
 {
     using (EShopDB db = new EShopDB())
     {
         db.BookInfo.Add(bookInfo);
         bool isSuccess = db.SaveChanges() > 0;
         return(isSuccess);
     }
 }
Esempio n. 6
0
 public bool InsertRecommend(Recommend recommend)
 {
     using (EShopDB db = new EShopDB())
     {
         db.Recommend.Add(recommend);
         bool isSuccess = db.SaveChanges() > 0;
         return(isSuccess);
     }
 }
Esempio n. 7
0
 public bool InsertBookSale(BookSale bookSale)
 {
     using (EShopDB db = new EShopDB())
     {
         db.BookSale.Add(bookSale);
         bool isSuccess = db.SaveChanges() > 0;
         return(isSuccess);
     }
 }
Esempio n. 8
0
 public bool InsertUserInfo(UserInfo userInfo)
 {
     using (EShopDB db = new EShopDB())
     {
         db.UserInfo.Add(userInfo);
         bool isSuccess = db.SaveChanges() > 0;
         return(isSuccess);
     }
 }
Esempio n. 9
0
 public BookType FindByName(string name)
 {
     using (EShopDB db = new EShopDB())
     {
         var obj = (from bt in db.BookType
                    where bt.TypeName.Contains(name)
                    select bt).FirstOrDefault();
         return(obj);
     }
 }
Esempio n. 10
0
 public int GetTypeCount(string type)
 {
     using (EShopDB db = new EShopDB())
     {
         int count = (from b in db.BookInfo
                      where b.Type == type
                      select b).Count();
         return(count);
     }
 }
Esempio n. 11
0
 public List <BookType> FindBookType()
 {
     using (EShopDB db = new EShopDB())
     {
         var obj = from bt in db.BookType
                   orderby bt.TypeCode
                   select bt;
         return(obj.ToList());
     }
 }
Esempio n. 12
0
 public int GetAdminCount(string search, int role)
 {
     using (EShopDB db = new EShopDB())
     {
         int count = (from u in db.UserInfo
                      where (u.Name.Contains(search) || u.LoginId.Contains(search)) && u.Role >= role
                      select u).Count();
         return(count);
     }
 }
Esempio n. 13
0
 public UserInfo FindByLoginId(string loginId)
 {
     using (EShopDB db = new EShopDB())
     {
         var obj = (from u in db.UserInfo
                    where u.LoginId == loginId
                    select u).FirstOrDefault();
         return(obj);
     }
 }
Esempio n. 14
0
 public BookSaleView FindById(string id)
 {
     using (EShopDB db = new EShopDB())
     {
         var obj = (from b in db.BookSaleView
                    where b.Id == id
                    select b).FirstOrDefault();
         return(obj);
     }
 }
Esempio n. 15
0
 public int GetCount(string search)
 {
     using (EShopDB db = new EShopDB())
     {
         int count = (from b in db.BookSaleView
                      where b.UserName.Contains(search) || b.SaleNum.Contains(search)
                      select b).Count();
         return(count);
     }
 }
Esempio n. 16
0
 public int GetCount(string search)
 {
     using (EShopDB db = new EShopDB())
     {
         int count = (from b in db.BookInfo
                      where b.Name.Contains(search) || b.Author.Contains(search)
                      select b).Count();
         return(count);
     }
 }
Esempio n. 17
0
 public int GetCount(string search)
 {
     using (EShopDB db = new EShopDB())
     {
         int count = (from r in db.RecommendView
                      where r.BookName.Contains(search) || r.ShowTitle.Contains(search)
                      select r).Count();
         return(count);
     }
 }
Esempio n. 18
0
 public int GetBuyCount(string uid)
 {
     using (EShopDB db = new EShopDB())
     {
         int count = (from b in db.BookSaleView
                      where b.UserId == uid
                      select b).Count();
         return(count);
     }
 }
Esempio n. 19
0
 public RecommendView FindDetailById(string id)
 {
     using (EShopDB db = new EShopDB())
     {
         var obj = (from r in db.RecommendView
                    where r.Id == id
                    select r).FirstOrDefault();
         return(obj);
     }
 }
Esempio n. 20
0
 public bool UpdateUserRole(UserInfo userInfo)
 {
     using (EShopDB db = new EShopDB())
     {
         var oldUserInfo = db.UserInfo.Find(userInfo.Id);
         oldUserInfo.Role = userInfo.Role;
         bool isSuccess = db.SaveChanges() > 0;
         return(isSuccess);
     }
 }
Esempio n. 21
0
 public BookType FindById(string id)
 {
     using (EShopDB db = new EShopDB())
     {
         var obj = (from bt in db.BookType
                    where bt.Id == id
                    select bt).FirstOrDefault();
         return(obj);
     }
 }
Esempio n. 22
0
 public OtherType FindById(string id)
 {
     using (EShopDB db = new EShopDB())
     {
         var obj = (from ot in db.OtherType
                    where ot.Id == id
                    select ot).FirstOrDefault();
         return(obj);
     }
 }
Esempio n. 23
0
 public int GetCount(string uid)
 {
     using (EShopDB db = new EShopDB())
     {
         int count = (from c in db.CartView
                      where c.UserId == uid
                      select c).Count();
         return(count);
     }
 }
Esempio n. 24
0
 public List <BookInfo> FindTopSale(int size)
 {
     using (EShopDB db = new EShopDB())
     {
         var obj = from b in db.BookInfo
                   orderby b.Sale descending
                   select b;
         List <BookInfo> list = obj.Take(size).ToList();
         return(list);
     }
 }
Esempio n. 25
0
 public List <SaleDetailView> FindSaleDetail(string BsId)
 {
     using (EShopDB db = new EShopDB())
     {
         var obj = from b in db.SaleDetailView
                   where b.BsId == BsId
                   select b;
         List <SaleDetailView> list = obj.ToList();
         return(list);
     }
 }
Esempio n. 26
0
 public List <BookInfo> FindByType(string type, int size)
 {
     using (EShopDB db = new EShopDB())
     {
         var obj = from b in db.BookInfo
                   where b.Type == type
                   orderby b.PublishDate descending
                   select b;
         List <BookInfo> list = obj.Take(size).ToList();
         return(list);
     }
 }
Esempio n. 27
0
 public List <BookInfo> FindByAuthor(string author)
 {
     using (EShopDB db = new EShopDB())
     {
         var obj = from b in db.BookInfo
                   where b.Author == author
                   orderby b.CreateDate descending
                   select b;
         List <BookInfo> list = obj.ToList();
         return(list);
     }
 }
Esempio n. 28
0
 public List <BookSaleView> FindByUserId(string uid)
 {
     using (EShopDB db = new EShopDB())
     {
         var obj = from b in db.BookSaleView
                   where b.UserId == uid
                   orderby b.CreateTime descending
                   select b;
         List <BookSaleView> list = obj.ToList();
         return(list);
     }
 }
Esempio n. 29
0
 public bool UpdateBookInfoStock(string id, int num)
 {
     using (EShopDB db = new EShopDB())
     {
         var bookInfo = db.BookInfo.Find(id);
         if (bookInfo.Stock == null)
         {
             bookInfo.Stock = 0;
         }
         bookInfo.Stock = bookInfo.Stock + num;
         return(db.SaveChanges() > 0);
     }
 }
Esempio n. 30
0
 public bool DeleteOtherType(string id)
 {
     using (EShopDB db = new EShopDB())
     {
         OtherType otherType = new OtherType()
         {
             Id = id
         };
         db.OtherType.Attach(otherType);
         db.OtherType.Remove(otherType);
         bool isSuccess = db.SaveChanges() > 0;
         return(isSuccess);
     }
 }