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); }
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); }