Example #1
0
 public bool Insert(OderDetail detail)
 {
     using (ThucLop db = new ThucLop())
     {
         db.OderDetails.Add(detail);
         db.SaveChanges();
         return true;
     }
 }
Example #2
0
 public int Insert(Order order)
 {
     using(ThucLop db = new ThucLop())
     {
         db.Orders.Add(order);
         db.SaveChanges();
         return order.ID;
     }
 }
Example #3
0
 /// <summary>
 /// Thêm Người Dùng
 /// </summary>
 /// <param name="user">Danh Sách Người Dùng</param>
 /// <returns></returns>
 public int Insert(User user)
 {
     using (ThucLop db = new ThucLop())
     {
         db.Users.Add(user);//Thêm Người Dùng
         db.SaveChanges();
         return user.ID;
     }
 }
Example #4
0
 /// <summary>
 /// Thêm Sản Phẩm
 /// </summary>
 /// <param name="user">Danh Sách Sản Phẩm</param>
 /// <returns></returns>
 public int Insert(Product product)
 {
     using (ThucLop db = new ThucLop())
     {
         db.Products.Add(product);//Thêm Sản Phẩm
         db.SaveChanges();
         return product.ID;
     }
 }
Example #5
0
 /// <summary>
 /// Sửa Người Dùng
 /// </summary>
 /// <param name="user">Người Dùng</param>
 /// <returns></returns>
 public bool Update(User user)
 {
     using (ThucLop db = new ThucLop())
     {
         var model= db.Users.Find(user.ID);
         if(model!=null)
         {
             model.Name = user.Name;
             if (!string.IsNullOrEmpty(user.Password))
             {
                 model.Password = user.Password;
             }
             model.Address = user.Address;
             model.Email = user.Email;
             model.ModifiedBy = user.ModifiedBy;
             model.ModifiedDate = DateTime.Now;
             db.SaveChanges();
             return true;
         }
         else
         { return false; }
       
     }
 }
Example #6
0
 public bool Signup(User user)
 {
     using (ThucLop db = new ThucLop())
     {
         if (user != null)
         {
             var User = db.Users.Add(user);
             db.SaveChanges();
             return true;
         }
         else
             return false;
     }
 }
Example #7
0
 public bool Delete(int ID)
 {
     using (ThucLop db = new ThucLop())
     {
         var user= db.Users.Find(ID);
         db.Users.Remove(user);
         db.SaveChanges();
         return true;
     }
 }
Example #8
0
        /// <summary>
        /// Sửa Người Dùng
        /// </summary>
        /// <param name="user">Người Dùng</param>
        /// <returns></returns>
        public bool Update(Product product)
        {
            using (ThucLop db = new ThucLop())
            {
                var model = db.Products.Find(product.ID);
                if (model != null)
                {
                    model.Name = product.Name;
                    model.Detail = product.Detail;
                    model.Price = product.Price;
                    model.ModifiedBy = product.ModifiedBy;
                    model.ModifiedDate = DateTime.Now;
                    model.PromotionPrice = product.PromotionPrice;
                    model.Image = product.Image;
                    model.MoreImages = product.MoreImages;
                    model.Quantity = product.Quantity;
                    model.Status = product.Status;
                    model.Code = product.Code;
                    model.Warranty = product.Warranty;
                    model.MetaTitle = product.MetaTitle;
                    model.ModifiedBy = product.ModifiedBy;
                    model.Description = model.Description;
                    model.MetaKeywords = product.MetaKeywords;
                    model.MetaDescriptions = product.MetaDescriptions;
                    model.CategoryID = product.CategoryID;
                    model.IncludedVAT = product.IncludedVAT;
                    model.TopHot = product.TopHot;
                    db.SaveChanges();
                    return true;
                }
                else
                { return false; }

            }
        }
Example #9
0
 public bool Delete(int ID)
 {
     using (ThucLop db = new ThucLop())
     {
         var product = db.Products.Find(ID);
         db.Products.Remove(product);
         db.SaveChanges();
         return true;
     }
 }