コード例 #1
0
        protected override CartItem GetEntity(AlbumContext entityContext, int id)
        {
            var query   = (from e in entityContext.CartItemSet where e.CartItemId == id select e);
            var results = query.FirstOrDefault();

            return(results);
        }
コード例 #2
0
 public IEnumerable <Order> GetCustomerOrders(int accountId)
 {
     using (AlbumContext entityContext = new AlbumContext()) {
         var query = from o in entityContext.OrderSet
                     where o.AccountId == accountId select o;
         return(query.ToList());
     }
 }
コード例 #3
0
 public CartItem GetByID(int cartId)
 {
     using (AlbumContext entityContext = new AlbumContext()) {
         var query = from c in entityContext.CartItemSet
                     where c.CartItemId == cartId select c;
         return(query.FirstOrDefault());
     }
 }
コード例 #4
0
 public Album GetAlbumTracksById(int albumId)
 {
     using (AlbumContext entityContext = new AlbumContext()) {
         var query = from a in entityContext.AlbumSet.Include("Tracks")
                     where a.AlbumId == albumId select a;
         return(query.FirstOrDefault());
     }
 }
コード例 #5
0
 public Account GetByLogin(string login)
 {
     using (AlbumContext entityContext = new AlbumContext()) {
         return((from a in entityContext.Users
                 where a.AccountSet.User.Email == login
                 select a.AccountSet).FirstOrDefault());
     }
 }
コード例 #6
0
 public IEnumerable <CartItem> GetAllCartItems()
 {
     using (AlbumContext entityContext = new AlbumContext()) {
         var query = from c in entityContext.CartItemSet
                     select c;
         return(query.ToList());
     }
 }
コード例 #7
0
 public IEnumerable <CartItem> GetCartItemsByCreatedDate(DateTime created)
 {
     using (AlbumContext entityContext = new AlbumContext()) {
         var query = from c in entityContext.CartItemSet
                     where c.Created < created && c.OrderId == 1
                     select c;
         return(query.ToList());
     }
 }
コード例 #8
0
 public IEnumerable <CartInfo> GetPendingCartItemsByAccountId(int accountId)
 {
     using (AlbumContext entityContext = new AlbumContext()) {
         var query = from c in entityContext.CartItemSet
                     join a in entityContext.AlbumSet on c.AlbumId equals a.AlbumId
                     where c.AccountId == accountId && c.OrderId == 1
                     select new CartInfo()
         {
             Title = a.Title, Image = a.Image, CartItem = c
         };
         return(query.ToList());
     }
 }
コード例 #9
0
 public IEnumerable <CustomerPurchaseInfo> GetCurrentCustomerPurchaseInfo()
 {
     using (AlbumContext entityContext = new AlbumContext()) {
         var query = from c in entityContext.CartItemSet
                     join u in entityContext.Users on c.AccountId equals u.AccountSet.AccountId
                     join a in entityContext.AlbumSet on c.AlbumId equals a.AlbumId
                     select new CustomerPurchaseInfo()
         {
             Customer = u.AccountSet,
             CartItem = c, Album = a
         };
         return(query.ToList());
     }
 }
コード例 #10
0
 public void TransferCartItemsToOrder(int orderId, int AccountId)
 {
     using (AlbumContext entityContext = new AlbumContext())
     {
         IQueryable <CartItem> items = from c in entityContext.CartItemSet
                                       where c.AccountId == AccountId && c.OrderId == 1
                                       select c;
         foreach (var item in items)
         {
             item.OrderId = orderId;
         }
         entityContext.SaveChanges();
     }
 }
コード例 #11
0
 public bool CartItemsContainAlbum(int albumId)
 {
     using (AlbumContext entityContext = new AlbumContext()) {
         var query = (from c in entityContext.CartItemSet
                      where c.AlbumId == albumId select c).FirstOrDefault();
         if (query == null)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
 }
コード例 #12
0
 public bool AlbumHasTracks(int albumId)
 {
     using (AlbumContext entityContext = new AlbumContext()) {
         var query = (from c in entityContext.AlbumSet
                      where c.AlbumId == albumId && c.Tracks.Count > 0
                      select c).FirstOrDefault();
         if (query == null)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
 }
コード例 #13
0
 public IEnumerable <Album> GetAllAlbumsPaged(out int totalCount, AlbumFilter filters,
                                              List <SortItem> sorts, int pageIndex = 0, int pageSize = 15)
 {
     using (AlbumContext entityContext = new AlbumContext()) {
         if (sorts.Count == 0)
         {
             sorts.Add(
                 new SortItem {
                 Column = "AlbumId", Direction = SortDirection.Ascending
             });
         }
         IQueryable <Album> query;
         query      = entityContext.AlbumSet;
         query      = Filter(filters, query);
         totalCount = query.Count();
         query      = Sort(sorts, query);
         query      = query.Skip((pageIndex) * pageSize).Take(pageSize);
         var result = query.ToArray();
         return(result);
     }
 }
コード例 #14
0
 protected override Order AddEntity(AlbumContext entityContext, Order entity)
 {
     return(entityContext.OrderSet.Add(entity));
 }
コード例 #15
0
 protected override Account GetEntity(AlbumContext entityContext, int id)
 {
     return((from a in entityContext.Users
             where a.AccountSet.AccountId == id
             select a.AccountSet).FirstOrDefault());
 }
コード例 #16
0
 protected override Album AddEntity(AlbumContext entityContext, Album entity)
 {
     return(entityContext.AlbumSet.Add(entity));
 }
コード例 #17
0
 protected override Album UpdateEntity(AlbumContext entityContext, Album entity)
 {
     return((from e in entityContext.AlbumSet where e.AlbumId == entity.AlbumId
             select e).FirstOrDefault());
 }
コード例 #18
0
 protected override IEnumerable <CartItem> GetEntities(AlbumContext entityContext)
 {
     return(from e in entityContext.CartItemSet select e);
 }
コード例 #19
0
 protected override CartItem UpdateEntity(AlbumContext entityContext, CartItem entity)
 {
     return((from e in entityContext.CartItemSet
             where e.CartItemId == entity.CartItemId
             select e).FirstOrDefault());
 }
コード例 #20
0
 protected override CartItem AddEntity(AlbumContext entityContext, CartItem entity)
 {
     return(entityContext.CartItemSet.Add(entity));
 }
コード例 #21
0
 protected override Track UpdateEntity(AlbumContext entityContext, Track entity)
 {
     return((from e in entityContext.TrackSet
             where e.TrackId == entity.TrackId
             select e).FirstOrDefault());
 }
コード例 #22
0
 protected override IEnumerable <Order> GetEntities(AlbumContext entityContext)
 {
     return(from e in entityContext.OrderSet select e);
 }
コード例 #23
0
 protected override IEnumerable <Account> GetEntities(AlbumContext entityContext)
 {
     throw new NotImplementedException();
 }
コード例 #24
0
 protected override IEnumerable <Track> GetEntities(AlbumContext entityContext)
 {
     return(from e in entityContext.TrackSet select e);
 }
コード例 #25
0
 protected override Track AddEntity(AlbumContext entityContext, Track entity)
 {
     return(entityContext.TrackSet.Add(entity));
 }
コード例 #26
0
 protected override Order UpdateEntity(AlbumContext entityContext, Order entity)
 {
     return((from e in entityContext.OrderSet
             where e.OrderId == entity.OrderId
             select e).FirstOrDefault());
 }
コード例 #27
0
 protected override Account UpdateEntity(AlbumContext entityContext, Account entity)
 {
     throw new NotImplementedException();
 }