예제 #1
0
        public IActionResult Add()
        {
            var model = new UISubCategoryListCategory();
            var c     = new CategoryRepository().GetAll("Id", "Name");

            if (c.Count > 0)
            {
                foreach (var item in c)
                {
                    model.Categores.Add(new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem(item.Name, item.Id.ToString()));
                }
            }

            return(View("AddOrUpdate", model));
        }
예제 #2
0
        public IActionResult AddOrUpdate(UISubCategoryListCategory model)
        {
            bool b;

            if (model.SubCategory.Id > 0)
            {
                b = repository.Update(model.SubCategory, model.SubCategory.Id);
            }
            else
            {
                b = repository.Insert(model.SubCategory) > 0;
            }
            if (b)
            {
                return(RedirectToAction("AllSubCategory"));
            }
            return(View("AddOrUpdate"));
        }