예제 #1
0
        public ActionResult DeleteProduct(int id)
        {
            tbl_Product      tb  = _db.tbl_Product.Where(u => u.ProductId == id).FirstOrDefault();
            ProductViewModel pvm = new ProductViewModel();

            pvm.ProductId          = tb.ProductId;
            pvm.ProductName        = tb.ProductName;
            pvm.ProductDescription = tb.ProductDescription;
            pvm.ProductPackingDate = tb.ProductPackingDate;
            pvm.ProductExpireDate  = tb.ProductExpireDate;
            tbl_Deals td = _db.tbl_Deals.Where(u => u.DealsId == id).FirstOrDefault();

            pvm.DealsName = td.DealsName;
            tbl_ProductCategory tpc = _db.tbl_ProductCategory.Where(u => u.CategoryId == tb.CategoryId).FirstOrDefault();

            pvm.CategoryName = tpc.CategoryName;
            tbl_ProductStatus tpss = _db.tbl_ProductStatus.Where(u => u.StatusId == tb.StatusId).FirstOrDefault();

            pvm.StatusName = tpss.StatusName;
            tbl_ProductStore tps = _db.tbl_ProductStore.Where(u => u.ProductId == tb.ProductId).FirstOrDefault();
            tbl_Store        ts  = _db.tbl_Store.Where(u => u.StoreId == tps.StoreId).FirstOrDefault();

            pvm.StoreName = ts.StoreName;
            return(View(pvm));
        }
예제 #2
0
        public ActionResult DeleteCategories(int id)
        {
            tbl_ProductCategory tb = _db.tbl_ProductCategory.Where(u => u.CategoryId == id).FirstOrDefault();

            _db.tbl_ProductCategory.Remove(tb);
            _db.SaveChanges();
            return(RedirectToAction("Category"));
        }
예제 #3
0
        public ActionResult DeleteConfirmed(short id)
        {
            tbl_ProductCategory tbl_ProductCategory = db.tbl_ProductCategory.Find(id);

            db.tbl_ProductCategory.Remove(tbl_ProductCategory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #4
0
        public ActionResult EditCategory(int id)
        {
            tbl_ProductCategory tb  = _db.tbl_ProductCategory.Where(p => p.CategoryId == id).FirstOrDefault();
            CategoryViewModel   cvm = new CategoryViewModel();

            cvm.CategoryId   = tb.CategoryId;
            cvm.CategoryName = tb.CategoryName;
            return(View(cvm));
        }
예제 #5
0
 public ActionResult Edit([Bind(Include = "id,name,description,createTime,updatedTime,createdBy,updatedBy")] tbl_ProductCategory tbl_ProductCategory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_ProductCategory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbl_ProductCategory));
 }
예제 #6
0
        public ActionResult Create([Bind(Include = "id,name,description,createTime,updatedTime,createdBy,updatedBy")] tbl_ProductCategory tbl_ProductCategory)
        {
            if (ModelState.IsValid)
            {
                db.tbl_ProductCategory.Add(tbl_ProductCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tbl_ProductCategory));
        }
        /// <summary>
        /// Gets the level.
        /// </summary>
        /// <param name="category">The category.</param>
        /// <returns></returns>
        public int GetLevel(tbl_ProductCategory category)
        {
            var level = 0;

            while (category != null)
            {
                level++;
                category = category.tbl_ProductCategory2;
            }

            return(level);
        }
예제 #8
0
        // GET: tbl_ProductCategory/Edit/5
        public ActionResult Edit(short?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_ProductCategory tbl_ProductCategory = db.tbl_ProductCategory.Find(id);

            if (tbl_ProductCategory == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_ProductCategory));
        }
        /// <summary>
        /// Gets the full name of the category.
        /// </summary>
        /// <param name="category">The category.</param>
        /// <param name="delimetr">The delimetr.</param>
        /// <returns></returns>
        public string GetCategoryFullName(tbl_ProductCategory category, string delimetr)
        {
            var result = string.Empty;

            while (category != null)
            {
                if (String.IsNullOrEmpty(result))
                {
                    result = category.Title;
                }
                else
                {
                    result = delimetr + result;
                }
                category = category.tbl_ProductCategory2;
            }
            return(result);
        }
예제 #10
0
 public ActionResult EditCategories(CategoryViewModel cvm)
 {
     if (ModelState.IsValid)
     {
         try
         {
             tbl_ProductCategory category = _db.tbl_ProductCategory.Where(p => p.CategoryId == cvm.CategoryId).FirstOrDefault();
             category.CategoryId   = cvm.CategoryId;
             category.CategoryName = cvm.CategoryName;
             _db.SaveChanges();
             ViewBag.Message = "Category Updated Successfully.";
             return(RedirectToAction("category"));
         }
         catch (Exception e)
         {
             return(View("Error", new HandleErrorInfo(e, "Admin", "EditCategory")));
         }
     }
     return(RedirectToAction("Category"));
 }
예제 #11
0
 public ActionResult InsertCategory(CategoryViewModel cvm)
 {
     if (ModelState.IsValid)
     {
         try
         {
             tbl_ProductCategory category = new tbl_ProductCategory();
             category.CategoryId   = cvm.CategoryId;
             category.CategoryName = cvm.CategoryName;
             _db.tbl_ProductCategory.Add(category);
             _db.SaveChanges();
             ViewBag.Message = "Category Created Successfully.";
             return(RedirectToAction("Category"));
         }
         catch (Exception e)
         {
             return(View("Error", new HandleErrorInfo(e, "Admin", "InsertCategory")));
         }
     }
     return(View());
 }