Exemplo n.º 1
0
 public void DeleteProduct(long id)
 {
     using (var dbContext = new BFUContext())
     {
         var pr = FindProduct(id);
         dbContext.Entry(pr).State = EntityState.Modified;
         dbContext.Products.Remove(pr);
         dbContext.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public void ChangeProduct(Product product)
 {
     using (var dbContext = new BFUContext())
     {
         Product pr = FindProduct(product.Id);
         pr = product;
         dbContext.Entry(pr).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public void TakeFromCart(long id)
 {
     using (var dbContext = new BFUContext())
     {
         Product pr = FindProduct(id);
         pr.ProductReturn();
         dbContext.Entry(pr).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
Exemplo n.º 4
0
 public void Sale(long prodId)
 {
     using (var dbContext = new BFUContext())
     {
         Product pr = FindProduct(prodId);
         pr.SaleProduct();
         dbContext.Entry(pr).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
Exemplo n.º 5
0
 public void ChangeClient(Client client)
 {
     using (var dbContext = new BFUContext())
     {
         Client cl = FindClient(client.Id);
         cl = client;
         dbContext.Entry(cl).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
Exemplo n.º 6
0
 public void ReturnToSale()
 {
     using (var dbContext = new BFUContext())
     {
         foreach (var p in dbContext.Products)
         {
             if ((DateTime.Now - p.DateBay) >= TimeSpan.FromMinutes(2) && p.Sold == 2)
             {
                 p.ProductReturn();
                 dbContext.Entry(p).State = EntityState.Modified;
             }
         }
         dbContext.SaveChanges();
     }
 }
Exemplo n.º 7
0
 public Product PutToCart(long prodId, long userId)
 {
     using (var dbContext = new BFUContext())
     {
         Product pr = FindProduct(prodId);
         pr.Sold    = 1;
         pr.DateBay = DateTime.Now;
         if (userId != 0)
         {
             pr.UserId = userId;
         }
         dbContext.Entry(pr).State = EntityState.Modified;
         dbContext.SaveChanges();
         return(pr);
     }
 }