Ejemplo n.º 1
0
 private void CheckInitData(int?id)
 {
     if (id == null)
     {
         return;
     }
     if (FileInfoDb.GetById(id.Value).IsInit)
     {
         throw new Exception("初始化数据无法修改");
     }
 }
Ejemplo n.º 2
0
        public ActionResult <ApiResult <string> > GetRazorModel([FromForm] string Id)
        {
            var result = new ApiResult <string>();

            result.Data += "[";
            if (!string.IsNullOrEmpty(Id))
            {
                var ids   = Id.Split(',').Select(it => it.Trim()).ToArray();
                var jsons = FileInfoDb.AsQueryable().Where(it => ids.Contains(it.Id.ToString())).Select(it => it.Json).ToList();
                result.Data += string.Join(",", jsons);
            }
            result.IsSuccess = true;
            result.Data     += "]";
            return(result);
        }
Ejemplo n.º 3
0
        public ActionResult <ApiResult <List <TreeModel> > > GetFileInfo()
        {
            List <TreeModel> trees = new List <TreeModel>();
            var databases          = FileInfoDb.GetList(it => it.IsDeleted == false);

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

            result.Data      = trees;
            result.IsSuccess = true;
            return(result);
        }
Ejemplo n.º 4
0
        public ActionResult <ApiResult <bool> > DeleteFileInfo([FromForm] string model)
        {
            var result = new ApiResult <bool>();

            if (!string.IsNullOrEmpty(model))
            {
                var list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <DatabaseViewModel> >(model);
                var exp  = Expressionable.Create <FileInfo>();
                foreach (var item in list)
                {
                    CheckInitData(item.Id);
                    exp.Or(it => it.Id == item.Id);
                }
                FileInfoDb.Update(it => new FileInfo()
                {
                    IsDeleted = true
                }, exp.ToExpression());
            }
            result.IsSuccess = true;
            return(result);
        }