예제 #1
0
        public int addCategory(string name)
        {
            Category res = new Category {
                CatId = getCatID(), CatName = name
            };

            _context.Categories.Add(res);
            _context.SaveChanges();
            return(res.CatId);
        }
예제 #2
0
 public bool CreateAccount(User_Accounts user)
 {
     try
     {
         _context.User_Accounts.Add(user);
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
예제 #3
0
 public bool AddCartToDb(Cart cart, int amount)
 {
     try
     {
         var item = _context.Carts.SingleOrDefault(p => p.ProductId == cart.ProductId);
         if (item == null)
         {
             cart.Amount = 1;
         }
         else
         {
             cart.Amount += amount;
         }
         _context.Carts.AddOrUpdate(cart);
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
예제 #4
0
        //public List<Order> AllOrderDetail(int id)
        //{
        //    var orderDetail = (from i in _context.Orders
        //                       where i.Orders_Detail == id
        //                       select i).ToList();
        //    return orderDetail;
        //}

        //thêm đơn hàng vô db
        public bool AddOrderMenuToDb(Order order, int amount)
        {
            try
            {
                order.Amount = amount;
                _context.Orders.Add(order);
                _context.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }