示例#1
0
        public async Task <ActionResult> StandardCategoryDelete(Guid id)
        {
            var standardCategoryService = new StandardCategoryService();
            await standardCategoryService.RemoveStandardCategory(id);

            return(RedirectToAction(nameof(StandardCategoryList)));
        }
示例#2
0
        public async Task <ActionResult> StandardCategoryDetails(Guid?id)
        {
            var standardCategoryService = new StandardCategoryService();

            if (id == null || !await standardCategoryService.ExistsStandardCategory(id.Value))
            {
                return(RedirectToAction(nameof(StandardCategoryList)));
            }
            return(View(await standardCategoryService.GetOneStandardCategoryById(id.Value)));
        }
示例#3
0
 public ActionResult CreateStandardCategory(StandardCategoryCreateViewModel model)
 {
     if (ModelState.IsValid)
     {
         IStandardCategoryService standardCategorySvc = new StandardCategoryService();
         standardCategorySvc.CreateStandardCategory(model.Name, model.CategoryCode);
         return(RedirectToAction(nameof(StandardCategoryList)));
     }
     ModelState.AddModelError("", @"您录入的信息有误");
     return(View());
 }
示例#4
0
        public async Task <ActionResult> StandardCategoryEdit(Guid id)
        {
            var standardCategoryService = new StandardCategoryService();
            var data = await standardCategoryService.GetOneStandardCategoryById(id);

            return(View(new StandardCategoryEditViewModel()
            {
                Id = data.Id,
                Name = data.Name,
                CategoryCode = data.CategoryCode,
            }));
        }
示例#5
0
        public async Task <ActionResult> StandardCategoryEdit(Models.StandardCategoryViewModels.StandardCategoryEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var standardCategoryService = new StandardCategoryService();
                await standardCategoryService.EditStandardCategory(model.Id, model.Name, model.CategoryCode);

                return(RedirectToAction(nameof(StandardCategoryList)));
            }
            else
            {
                await new StandardCategoryService().CreateStandardCategory(model.Name, model.CategoryCode);
                return(View(model));
            }
        }
示例#6
0
        public async Task <ActionResult> StandardCategoryList(int pageIndex = 1, int pageSize = 20)
        {
            //总页码、当前页码、可显示总页码
            var standardCategorySvc = new StandardCategoryService();
            //当前第n页数据
            var articles = await standardCategorySvc.GetAllStandardCategory(pageIndex, pageSize, false);

            //总个数
            var dataCount = await standardCategorySvc.GetDataCount();

            //绑定分页
            var list = new PagedList <StandardCategoryDto>(articles, pageIndex, pageSize, dataCount);

            return(View(list));
        }