Пример #1
0
 public User GetByUsername(string username)
 {
     using (AuctionContext auctionContext = new AuctionContext())
     {
         return(auctionContext.Users.FirstOrDefault(e => e.Username == username));
     }
 }
Пример #2
0
 public Lot GetById(int id)
 {
     using (AuctionContext auctionContext = new AuctionContext())
     {
         return(auctionContext.Lots.Include(e => e.Seller).FirstOrDefault(e => e.Id == id));
     }
 }
Пример #3
0
        protected static AuctionContext CreateContext()
        {
            var result = new AuctionContext();

            Database.SetInitializer <AuctionContext>(new AuctionInitializer());
            return(result);
        }
Пример #4
0
 public void Remove(Lot lot)
 {
     using (AuctionContext auctionContext = new AuctionContext())
     {
         auctionContext.Entry <Lot>(lot).State = EntityState.Deleted;
         auctionContext.SaveChanges();
     }
 }
Пример #5
0
 public void Edit(Lot lot)
 {
     using (AuctionContext auctionContext = new AuctionContext())
     {
         auctionContext.Entry <Lot>(lot).State = EntityState.Modified;
         auctionContext.SaveChanges();
     }
 }
Пример #6
0
 public void Add(Lot lot)
 {
     using (AuctionContext auctionContext = new AuctionContext())
     {
         auctionContext.Lots.Add(lot);
         auctionContext.SaveChanges();
     }
 }
Пример #7
0
 public void Registartion(User user)
 {
     using (AuctionContext auctionContext = new AuctionContext())
     {
         auctionContext.Users.Add(user);
         auctionContext.SaveChanges();
     }
 }
Пример #8
0
 public void Edit(User user)
 {
     using (AuctionContext auctionContext = new AuctionContext())
     {
         auctionContext.Entry <User>(user).State = EntityState.Modified;
         auctionContext.SaveChanges();
     }
 }
Пример #9
0
 public bool Login(User user)
 {
     using (AuctionContext auctionContext = new AuctionContext())
     {
         return(auctionContext.Users.Any(e =>
                                         e.HashPassword == user.HashPassword &&
                                         e.Username == user.Username));
     }
 }
Пример #10
0
 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));
     }
 }
Пример #11
0
 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();
     }
 }
Пример #12
0
 public IEnumerable <Lot> GetAll()
 {
     using (AuctionContext auctionContext = new AuctionContext())
     {
         auctionContext.Lots
         .Include(e => e.Seller)
         .Include(e => e.Buyer)
         .Load();
         return(auctionContext.Lots.Local);
     }
 }
Пример #13
0
 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());
     }
 }
Пример #14
0
 protected static AuctionContext CreateContext()
 {
     var result = new AuctionContext();
                 Database.SetInitializer<AuctionContext>(new AuctionInitializer());
                 return result;
 }