Пример #1
0
        public ActionResult <ApiResult <TableModel <CommonFieldGridViewModel> > > GetCommonFieldList([FromForm] CommonFieldViewModel model)
        {
            var result = new ApiResult <TableModel <CommonFieldGridViewModel> >();

            result.Data = new TableModel <CommonFieldGridViewModel>();
            int count = 0;
            var list  = CommonFieldDb.AsQueryable()
                        .ToPageList(model.PageIndex, model.PageSize, ref count);

            result.Data.Rows       = mapper.Map <List <CommonFieldGridViewModel> >(list);
            result.Data.Total      = count;
            result.Data.PageSize   = model.PageSize;
            result.Data.PageNumber = model.PageIndex;
            result.IsSuccess       = true;
            return(result);
        }
Пример #2
0
        public ActionResult <ApiResult <List <TreeModel> > > GetCommonFiled()
        {
            List <TreeModel> trees = new List <TreeModel>();
            var datas = CommonFieldDb.GetList();

            foreach (var data in datas)
            {
                trees.Add(new TreeModel()
                {
                    Id           = data.Id.ToString(),
                    Title        = data.ClassProperName,
                    IsSelectable = true
                });
            }
            ApiResult <List <TreeModel> > result = new ApiResult <List <TreeModel> >();

            result.Data      = trees;
            result.IsSuccess = true;
            return(result);
        }
Пример #3
0
        public ActionResult <ApiResult <bool> > DeleteCommonField([FromForm] string model)
        {
            var result = new ApiResult <bool>();

            if (!string.IsNullOrEmpty(model))
            {
                var list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <CommonFieldViewModel> >(model);
                // var isInit = Db.Queryable<CommonField>().In(list.Select(it=>it.Id).ToList()).Any(it => it.IsInit == true);
                // base.Check(isInit, "无法删除初始化数据");
                var exp = Expressionable.Create <CommonField>();
                foreach (var item in list)
                {
                    exp.Or(it => it.Id == item.Id);
                }
                CommonFieldDb.Update(it => new CommonField()
                {
                    IsDeleted = true
                }, exp.ToExpression());
            }
            result.IsSuccess = true;
            return(result);
        }
Пример #4
0
        public ActionResult <ApiResult <string> > SaveCommField([FromForm] string Field, [FromForm] string model, [FromForm] int?dbid)
        {
            ApiResult <string> result = new ApiResult <string>();
            var fields                    = (Field + "").Split(',').Where(it => !string.IsNullOrEmpty(it)).ToList();
            var fieldInfoList             = CommonFieldDb.GetList(it => fields.Contains(it.Id.ToString()));
            var list                      = Newtonsoft.Json.JsonConvert.DeserializeObject <List <CodeTableGridViewModel> >(model);
            List <CodeColumns> addcolumns = new List <CodeColumns>();

            foreach (var item in list)
            {
                var columns = CodeColumnsDb.GetList(it => it.CodeTableId == item.Id);

                foreach (var filedItem in fieldInfoList)
                {
                    if (!columns.Any(y => y.DbColumnName.ToLower() == filedItem.DbColumnName.ToLower()) && !columns.Any(y => y.ClassProperName.ToLower() == filedItem.ClassProperName.ToLower()))
                    {
                        if (!addcolumns.Any(it => it.DbColumnName == filedItem.DbColumnName && it.CodeTableId == Convert.ToInt32(item.Id)))
                        {
                            addcolumns.Add(new CodeColumns()
                            {
                                CodeTableId     = Convert.ToInt32(item.Id),
                                DbColumnName    = filedItem.DbColumnName,
                                ClassProperName = filedItem.ClassProperName,
                                CodeType        = CodeTypeDb.GetById(filedItem.CodeType).Name,
                                IsIdentity      = filedItem.IsIdentity,
                                IsPrimaryKey    = filedItem.IsPrimaryKey,
                                Required        = filedItem.Required,
                                Description     = filedItem.Description
                            });
                        }
                    }
                }
            }
            CodeColumnsDb.InsertRange(addcolumns);
            result.IsSuccess = true;
            result.Data      = "追加成功";
            return(result);
        }