예제 #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));
        }
예제 #2
0
        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;
 }