Exemplo n.º 1
0
        public ActionResult Create(CateProductModels model)
        {
            var dao    = new CateProductDao();
            var result = dao.CheckProduct(model.Name);

            if (ModelState.IsValid)
            {
                if (result == false)
                {
                    var session = (UserSession)Session[CommomConstants.USER_SESSION];
                    model.CreatedDate  = DateTime.Now;
                    model.ModifiedDate = DateTime.Now;
                    model.ModifiedBy   = session.TenTK;
                    model.CreatedBy    = session.TenTK;
                    var id = new CateProductDao().Insert(model);
                    if (id == true)
                    {
                        SetAlert("Thêm danh mục thành công", "success");
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        SetAlert("Thêm danh mục thất bại", "error");
                    }
                }
                else
                {
                    SetAlert("Tên danh mục đã tồn tại", "error");
                }
            }
            return(View(model));
        }
Exemplo n.º 2
0
        // GET: Admin/CateProduct
        public ActionResult Index()
        {
            var dao   = new CateProductDao();
            var model = dao.ListAllPaging();

            return(View(model));
        }
Exemplo n.º 3
0
        public JsonResult ChangeStatus(string id)
        {
            var result = new CateProductDao().ChangeStatus(id);

            return(Json(new
            {
                status = result
            }));
        }
Exemplo n.º 4
0
        public ActionResult Edit(CateProductModels category, string id)
        {
            if (ModelState.IsValid)
            {
                var session = (UserSession)Session[CommomConstants.USER_SESSION];

                var dao = new CateProductDao();
                category.ModifiedDate = DateTime.Now;
                category.ModifiedBy   = session.TenTK;
                var result = dao.update(category, id);
                if (result)
                {
                    SetAlert("Sửa danh mục sản phẩm thành công", "success");
                    return(RedirectToAction("Index"));
                }
                else
                {
                    SetAlert("Sửa danh mục không thành công", "error");
                }
            }
            return(View(category));
        }
Exemplo n.º 5
0
        public ActionResult Edit(string ID)
        {
            var category = new CateProductDao().ViewDetail(ID);

            return(View(category));
        }
Exemplo n.º 6
0
        public ActionResult Detail(string id)
        {
            var result = new CateProductDao().ViewDetail(id);

            return(View(result));
        }
        public void SetViewBag(long?selectedID = null)
        {
            var dao = new CateProductDao();

            ViewBag.CategoryID = new SelectList(dao.ListAll(), "ID", "Name", selectedID);
        }