示例#1
0
        // GET: Category/Delete/5
        public ActionResult Delete(int id)
        {
            var      lista    = CategoryBusiness.GetCategoryList();
            Category category = lista.Find(x => x.Id == id);

            return(View(category));
        }
        public CategoryList()
        {
            CategoryBusiness categoryBusiness = new CategoryBusiness();
            var list = categoryBusiness.GetCategoryList();

            foreach (var category in list)
            {
                Add(category);
            }
        }
示例#3
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
                var      lista    = CategoryBusiness.GetCategoryList();
                Category category = lista.Find(x => x.Id == id);
                lista.Remove(category);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#4
0
 private void LoadData()
 {
     _CategoryBusiness = new CategoryBusiness();
     currentAction     = (int)ACTION.LOADING;
     ListCategory      = _CategoryBusiness.GetCategoryList();
     dgvListCategory.Rows.Clear();
     for (int i = 0; i < ListCategory.Count; i++)
     {
         int inDex = dgvListCategory.Rows.Add();
         dgvListCategory.Rows[inDex].Cells[0].Value = ListCategory[i].Id;
         dgvListCategory.Rows[inDex].Cells[1].Value = ListCategory[i].Name;
     }
     currentAction = (int)ACTION.NONE;
     if (ListCategory.Count > 0)
     {
         dgvListCategory.Rows[0].Selected = true;
     }
 }
示例#5
0
        public ActionResult Edit(int id, string name)
        {
            try
            {
                // TODO: Add update logic here
                var      lista    = CategoryBusiness.GetCategoryList();
                Category category = lista.Find(x => x.Id == id);
                category.name      = name;
                category.ChangedOn = DateTime.Now;


                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#6
0
 private void LoadComboBoxCategory()
 {
     #region combobox Category
     _CategoryBusiness = new CategoryBusiness();
     List <CategoryDTO> lstCategory = new List <CategoryDTO>();
     CategoryDTO        category    = new CategoryDTO();
     category.Id   = -1;
     category.Name = "Chọn Danh Mục";
     lstCategory.Add(category);
     _lstCategory = _CategoryBusiness.GetCategoryList();
     foreach (CategoryDTO item in _lstCategory)
     {
         lstCategory.Add(item);
     }
     cbCategory.DataSource    = lstCategory;
     cbCategory.DisplayMember = "Name";
     cbCategory.ValueMember   = "Id";
     #endregion
 }
示例#7
0
        // GET: Category
        public ActionResult Index()
        {
            var lista = CategoryBusiness.GetCategoryList();

            return(View(lista));
        }
示例#8
0
 public Category()
 {
     this.CreatedOn = DateTime.Now;
     this.ChangedOn = DateTime.Now;
     Id             = CategoryBusiness.GetCategoryList().Count;
 }