Example #1
0
        public void DeletePhoneAmount(int id, int amount)
        {
            var phone = GetPhone(id);

            phone.Amount -= amount;
            _context.SaveChanges();
        }
Example #2
0
        public PhonesController(PhonesContext context)
        {
            db = context;

            if (!db.Phones.Any())
            {
                db.Phones.Add(new Phones {
                    Name = "Huawei p20 pro", Brend = "Huawei", Price = 1290.00m
                });
                db.Phones.Add(new Phones {
                    Name = "Iphone 7", Brend = "Apple inc.", Price = 990.00m
                });
                db.Phones.Add(new Phones {
                    Name = "Xiaomi Redmi 5", Brend = "Xiaomi", Price = 349.00m
                });
                db.SaveChanges();
            }
        }
Example #3
0
 public void Create(Order order)
 {
     _context.Orders.Add(order);
     _context.SaveChanges();
 }
Example #4
0
 public void Create(Reservation reservation)
 {
     _context.Reservations.Add(reservation);
     _context.SaveChanges();
 }
Example #5
0
 public void Add(T entity)
 {
     _context.Set <T>().Add(entity);
     _context.SaveChanges();
 }