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); }
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()); } }
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()); } }
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()); } }
public IEnumerable <CartItem> GetAllCartItems() { using (AlbumContext entityContext = new AlbumContext()) { var query = from c in entityContext.CartItemSet select c; return(query.ToList()); } }
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()); } }
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()); } }
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()); } }
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(); } }
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); } } }
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); } } }
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); } }
protected override Order AddEntity(AlbumContext entityContext, Order entity) { return(entityContext.OrderSet.Add(entity)); }
protected override Account GetEntity(AlbumContext entityContext, int id) { return((from a in entityContext.Users where a.AccountSet.AccountId == id select a.AccountSet).FirstOrDefault()); }
protected override Album AddEntity(AlbumContext entityContext, Album entity) { return(entityContext.AlbumSet.Add(entity)); }
protected override Album UpdateEntity(AlbumContext entityContext, Album entity) { return((from e in entityContext.AlbumSet where e.AlbumId == entity.AlbumId select e).FirstOrDefault()); }
protected override IEnumerable <CartItem> GetEntities(AlbumContext entityContext) { return(from e in entityContext.CartItemSet select e); }
protected override CartItem UpdateEntity(AlbumContext entityContext, CartItem entity) { return((from e in entityContext.CartItemSet where e.CartItemId == entity.CartItemId select e).FirstOrDefault()); }
protected override CartItem AddEntity(AlbumContext entityContext, CartItem entity) { return(entityContext.CartItemSet.Add(entity)); }
protected override Track UpdateEntity(AlbumContext entityContext, Track entity) { return((from e in entityContext.TrackSet where e.TrackId == entity.TrackId select e).FirstOrDefault()); }
protected override IEnumerable <Order> GetEntities(AlbumContext entityContext) { return(from e in entityContext.OrderSet select e); }
protected override IEnumerable <Account> GetEntities(AlbumContext entityContext) { throw new NotImplementedException(); }
protected override IEnumerable <Track> GetEntities(AlbumContext entityContext) { return(from e in entityContext.TrackSet select e); }
protected override Track AddEntity(AlbumContext entityContext, Track entity) { return(entityContext.TrackSet.Add(entity)); }
protected override Order UpdateEntity(AlbumContext entityContext, Order entity) { return((from e in entityContext.OrderSet where e.OrderId == entity.OrderId select e).FirstOrDefault()); }
protected override Account UpdateEntity(AlbumContext entityContext, Account entity) { throw new NotImplementedException(); }