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

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