Пример #1
0
        public IActionResult ModuleDetail(int id, int pid = 0)
        {
            var data = new AdModule();

            if (id > 0)
            {
                data = DefaultStorage.AdModuleGet(id);
            }
            return(PartialView(data));
        }
Пример #2
0
        public IActionResult AdItemList(int moduleId, int page = 1, int size = 20, string keyword = null, bool?status = null)
        {
            var model = new AdItemListModel();

            model.Keyword  = keyword;
            model.ModuleId = moduleId;
            model.Module   = DefaultStorage.AdModuleGet(moduleId);
            model.Items    = DefaultStorage.AdItemPagedList(moduleId, page, size, keyword, status);
            return(View(model));
        }
Пример #3
0
        public async Task <IActionResult> ModuleDetail(int id, AdModule model, int pid = 0)
        {
            var now = DateTime.Now;

            var result = new Result();

            if (model.Name.IsNullOrEmpty())
            {
                result.Error("请输入中文名称");
                return(Json(result));
            }

            if (id > 0 && pid == 0)
            {
                var old = DefaultStorage.AdModuleGet(id);
                if (old == null)
                {
                    result.Message = "数据不存在";
                    return(Json(result));
                }

                var status = await TryUpdateModelAsync(old);

                if (status)
                {
                    result.Status = DefaultStorage.AdModuleUpdate(old);
                    if (!result.Status)
                    {
                        result.Message = "更新失败";
                    }
                }
                else
                {
                    result.Message = "参数有误";
                }
                return(Json(result));
            }

            if (id == 0 && pid == 0)
            {
                result.Message = "参数错误";
                return(Json(result));
            }
            model.Pid        = pid;
            model.Extra      = string.Empty;
            model.CreatedOn  = now;
            model.ModifiedBy = string.Empty;
            model.ModifiedOn = now;

            var hs = GetParendIds(pid);

            model.Depth = hs.Count + 1;
            model.Path  = string.Join(",", hs);

            var newId = DefaultStorage.AdModuleCreate(model);

            if (result.Status = newId > 0)
            {
                hs.Add(newId);//补全path
                var path = string.Join(",", hs);
                DefaultStorage.AdModulePathUpdate(newId, path);
                result.Success();
            }

            return(Json(result));
        }
Пример #4
0
        public IActionResult ModuleData(int id, bool current = false)
        {
            var data = DefaultStorage.AdModuleGet(id, true, current);

            return(Json(data));
        }