Example #1
0
 public void Edit(Product product)
 {
     using (var dbContext = new DataContext())
     {
         dbContext.Entry(product).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
Example #2
0
 public static void Edit(Adress adress)
 {
     using (var dbContext = new DataContext())
     {
         dbContext.Entry(adress).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
 public void Edit(Category category)
 {
     using (var dbContext = new DataContext())
     {
         dbContext.Entry(category).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
 public void Edit(int id, int idParent)
 {
     using (var dbContext = new DataContext())
     {
         Category category = Find(id);
         category.Parent = Find(idParent);
         dbContext.Entry(category).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
Example #5
0
 public int AddOrderProduct(OrderProduct orderProduct)
 {
     using (var dbContext = new DataContext())
     {
         int id = dbContext.OrderProducts.Add(orderProduct).Id;
         var product = dbContext.Store.Find(orderProduct.ProductId);
         product.Quantity--;
         dbContext.Entry(product).State = EntityState.Modified;
         dbContext.SaveChanges();
         return id;
     }
 }
Example #6
0
        public static void Delete(int id)
        {
            using (var dbContext = new DataContext())
            {
                Picture pic = dbContext.Pictures.Find(id);

                var product = dbContext.Products.Find(pic.ProductId);
                product.Picture.Remove(pic);
                dbContext.Pictures.Remove(pic);
                dbContext.Entry(product).State = EntityState.Modified;
                dbContext.SaveChanges();
            }
        }
Example #7
0
 public static void Add(Picture picture)
 {
     using (var dbContext = new DataContext())
     {
         dbContext.Pictures.Add(picture);
         var product = dbContext.Products.Find(picture.ProductId);
         List<Picture> listPicture = product.Picture.ToList();
         listPicture.Add(picture);
         product.Picture = listPicture;
         dbContext.Entry(product).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
        public static void Add(String text, int productId, int userId)
        {
            using (var dbContext = new DataContext())
            {
                var listProduct = new List<Product>();

                var comment = new Description() {
                    TextDescription = text,
                    Data = DateTime.Now,
                    UserId = userId
                };
                var product = dbContext.Products.Find(productId);
                product.Descriptions.Add(comment);

                var user = dbContext.Users.Find(userId);
                user.Descriptions.Add(comment);
                dbContext.Entry(user).State = EntityState.Modified;

                dbContext.Descriptions.Add(comment);
                dbContext.Entry(product).State = EntityState.Modified;
                dbContext.SaveChanges();
            }
        }