Example #1
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 #2
0
 public ActionResult EditProduct(Product product)
 {
     if (ModelState.IsValid)
     {
         var dao = new ProductDAO();
         var result = dao.Update(product);
         if (result)
         {
             SetAlert("SửaThành Công", "success");
             return RedirectToAction("ViewProduct", "Product");
         }
     }
     else
     {
         ModelState.AddModelError("", "Cập Nhập Không Thành Công");
     }
     return RedirectToAction("ViewProduct");
 }
Example #3
0
 public ActionResult CreateProduct(Product product)
 {
     if (ModelState.IsValid)
     {
         if (product.CreatedDate == null)
         {
             product.CreatedDate = DateTime.Now;
         }
         var dao = new ProductDAO();
         int id = dao.Insert(product);
         if (id > 0)
         {
             SetAlert("Thêm Thành Công", "success");
             return RedirectToAction("ViewProduct", "Product");
         }
     }
     else
     {
         ModelState.AddModelError("", "Thêm Không Thành Công");
     }
     return RedirectToAction("ViewProduct");
 }
Example #4
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; }

            }
        }