Ejemplo n.º 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);
        }
Ejemplo n.º 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());
     }
 }
Ejemplo n.º 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());
     }
 }
Ejemplo n.º 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());
     }
 }
 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());
     }
 }
Ejemplo n.º 6
0
 public IEnumerable <CartItem> GetAllCartItems()
 {
     using (AlbumContext entityContext = new AlbumContext()) {
         var query = from c in entityContext.CartItemSet
                     select c;
         return(query.ToList());
     }
 }
Ejemplo n.º 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());
     }
 }
Ejemplo n.º 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());
     }
 }
Ejemplo n.º 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());
     }
 }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 14
0
 protected override Order AddEntity(AlbumContext entityContext, Order entity)
 {
     return(entityContext.OrderSet.Add(entity));
 }
Ejemplo n.º 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());
 }
Ejemplo n.º 16
0
 protected override Album AddEntity(AlbumContext entityContext, Album entity)
 {
     return(entityContext.AlbumSet.Add(entity));
 }
Ejemplo n.º 17
0
 protected override Album UpdateEntity(AlbumContext entityContext, Album entity)
 {
     return((from e in entityContext.AlbumSet where e.AlbumId == entity.AlbumId
             select e).FirstOrDefault());
 }
Ejemplo n.º 18
0
 protected override IEnumerable <CartItem> GetEntities(AlbumContext entityContext)
 {
     return(from e in entityContext.CartItemSet select e);
 }
Ejemplo n.º 19
0
 protected override CartItem UpdateEntity(AlbumContext entityContext, CartItem entity)
 {
     return((from e in entityContext.CartItemSet
             where e.CartItemId == entity.CartItemId
             select e).FirstOrDefault());
 }
Ejemplo n.º 20
0
 protected override CartItem AddEntity(AlbumContext entityContext, CartItem entity)
 {
     return(entityContext.CartItemSet.Add(entity));
 }
Ejemplo n.º 21
0
 protected override Track UpdateEntity(AlbumContext entityContext, Track entity)
 {
     return((from e in entityContext.TrackSet
             where e.TrackId == entity.TrackId
             select e).FirstOrDefault());
 }
Ejemplo n.º 22
0
 protected override IEnumerable <Order> GetEntities(AlbumContext entityContext)
 {
     return(from e in entityContext.OrderSet select e);
 }
Ejemplo n.º 23
0
 protected override IEnumerable <Account> GetEntities(AlbumContext entityContext)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 24
0
 protected override IEnumerable <Track> GetEntities(AlbumContext entityContext)
 {
     return(from e in entityContext.TrackSet select e);
 }
Ejemplo n.º 25
0
 protected override Track AddEntity(AlbumContext entityContext, Track entity)
 {
     return(entityContext.TrackSet.Add(entity));
 }
Ejemplo n.º 26
0
 protected override Order UpdateEntity(AlbumContext entityContext, Order entity)
 {
     return((from e in entityContext.OrderSet
             where e.OrderId == entity.OrderId
             select e).FirstOrDefault());
 }
Ejemplo n.º 27
0
 protected override Account UpdateEntity(AlbumContext entityContext, Account entity)
 {
     throw new NotImplementedException();
 }