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

            Database.SetInitializer <AuctionContext>(new AuctionInitializer());
            return(result);
        }
Example #4
0
 public void Remove(Lot lot)
 {
     using (AuctionContext auctionContext = new AuctionContext())
     {
         auctionContext.Entry <Lot>(lot).State = EntityState.Deleted;
         auctionContext.SaveChanges();
     }
 }
Example #5
0
 public void Edit(Lot lot)
 {
     using (AuctionContext auctionContext = new AuctionContext())
     {
         auctionContext.Entry <Lot>(lot).State = EntityState.Modified;
         auctionContext.SaveChanges();
     }
 }
Example #6
0
 public void Add(Lot lot)
 {
     using (AuctionContext auctionContext = new AuctionContext())
     {
         auctionContext.Lots.Add(lot);
         auctionContext.SaveChanges();
     }
 }
Example #7
0
 public void Registartion(User user)
 {
     using (AuctionContext auctionContext = new AuctionContext())
     {
         auctionContext.Users.Add(user);
         auctionContext.SaveChanges();
     }
 }
Example #8
0
 public void Edit(User user)
 {
     using (AuctionContext auctionContext = new AuctionContext())
     {
         auctionContext.Entry <User>(user).State = EntityState.Modified;
         auctionContext.SaveChanges();
     }
 }
Example #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));
     }
 }
Example #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));
     }
 }
Example #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();
     }
 }
Example #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);
     }
 }
Example #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());
     }
 }
 protected static AuctionContext CreateContext()
 {
     var result = new AuctionContext();
                 Database.SetInitializer<AuctionContext>(new AuctionInitializer());
                 return result;
 }