public User GetByUsername(string username) { using (AuctionContext auctionContext = new AuctionContext()) { return(auctionContext.Users.FirstOrDefault(e => e.Username == username)); } }
public Lot GetById(int id) { using (AuctionContext auctionContext = new AuctionContext()) { return(auctionContext.Lots.Include(e => e.Seller).FirstOrDefault(e => e.Id == id)); } }
protected static AuctionContext CreateContext() { var result = new AuctionContext(); Database.SetInitializer <AuctionContext>(new AuctionInitializer()); return(result); }
public void Remove(Lot lot) { using (AuctionContext auctionContext = new AuctionContext()) { auctionContext.Entry <Lot>(lot).State = EntityState.Deleted; auctionContext.SaveChanges(); } }
public void Edit(Lot lot) { using (AuctionContext auctionContext = new AuctionContext()) { auctionContext.Entry <Lot>(lot).State = EntityState.Modified; auctionContext.SaveChanges(); } }
public void Add(Lot lot) { using (AuctionContext auctionContext = new AuctionContext()) { auctionContext.Lots.Add(lot); auctionContext.SaveChanges(); } }
public void Registartion(User user) { using (AuctionContext auctionContext = new AuctionContext()) { auctionContext.Users.Add(user); auctionContext.SaveChanges(); } }
public void Edit(User user) { using (AuctionContext auctionContext = new AuctionContext()) { auctionContext.Entry <User>(user).State = EntityState.Modified; auctionContext.SaveChanges(); } }
public bool Login(User user) { using (AuctionContext auctionContext = new AuctionContext()) { return(auctionContext.Users.Any(e => e.HashPassword == user.HashPassword && e.Username == user.Username)); } }
public User GetByUsername(string username) { using (AuctionContext auctionContext = new AuctionContext()) { return(auctionContext.Users.Include(e => e.PlacedLots) .Include(e => e.PurchasedLots) .FirstOrDefault(e => e.Username == username)); } }
public void Buy(User user, Lot lot) { using (AuctionContext auctionContext = new AuctionContext()) { lot.Buyer = user; lot.IdBuyer = user.Id; auctionContext.Entry <Lot>(lot).State = EntityState.Modified; auctionContext.SaveChanges(); } }
public IEnumerable <Lot> GetAll() { using (AuctionContext auctionContext = new AuctionContext()) { auctionContext.Lots .Include(e => e.Seller) .Include(e => e.Buyer) .Load(); return(auctionContext.Lots.Local); } }
public IEnumerable <Lot> GetAll() { using (AuctionContext auctionContext = new AuctionContext()) { return(auctionContext.Lots .Include(e => e.Seller) .Include(e => e.Seller.PurchasedLots) .Include(e => e.Seller.PlacedLots) .Include(e => e.Buyer) .Include(e => e.Buyer.PlacedLots) .Include(e => e.Buyer.PurchasedLots) .ToList()); } }
protected static AuctionContext CreateContext() { var result = new AuctionContext(); Database.SetInitializer<AuctionContext>(new AuctionInitializer()); return result; }