public IActionResult Explore(int pid) { var did = 0; var now = DateTime.Now; var identity = User; var model = new ExploreModel(); var data = DefaultStorage.WeedDirList(identity.Id); if (data.Count == 0) { var o = new WeedDir(); o.Pid = 0; o.Name = "目录"; o.Depth = 1; o.UserId = 1; o.Status = true; //o.CreatedBy = o.CreatedBy; o.CreatedOn = now; //o.ModifiedBy = o.ModifiedBy; o.ModifiedOn = now; DefaultStorage.WeedDirCreate(o); data = DefaultStorage.WeedDirList(identity.Id); } var hierarchy = data.Select(x => new Node { Id = x.First.ToString(), Text = x.Third, Pid = x.Second.ToString() }).ToHierarchy(pid.ToString()); model.Nodes = hierarchy; //var model = new ExploreModel(); //if (!id.IsNullOrEmpty()) //{ // var file = DefaultStorage.WeedFileGet(id); // if (file != null) // { // did = file.Did; // } //} //else //{ // // var dir=DefaultStorage.WeedDirGet() //} //if (identity) //{ // did = DefaultStorage.WeedDirExist(identity.Id); // if (did == 0) // { // var o = new WeedDir(); // did = DefaultStorage.WeedDirCreate(o); // } // model.Files = DefaultStorage.WeedFilePagedList(identity.Id, did); //} return(View(model)); }
///<summary> /// 目录 更新 ///</summary> ///<param name="o">WeedDir</param> ///<returns></returns> public bool WeedDirUpdate(WeedDir o) { return(Try(nameof(WeedDirUpdate), () => { var cmd = SqlBuilder.Update("WeedDir") .Column("Name", o.Name) .Column("Depth", o.Depth) .Column("Badge", o.Badge) .Column("Extra", o.Extra) //.Column("UserId", o.UserId) .Column("Status", o.Status) //.Column("CreatedBy", o.CreatedBy) //.Column("CreatedOn", o.CreatedOn) .Column("ModifiedBy", o.ModifiedBy) .Column("ModifiedOn", o.ModifiedOn) .Where("Id=@id", new { o.Id }) .ToCommand(); return WeedConn.Execute(cmd) > 0; })); }
///<summary> /// 目录 创建 ///</summary> ///<param name="o">WeedDir</param> ///<returns></returns> public int WeedDirCreate(WeedDir o) { return(Try(nameof(WeedDirCreate), () => { var cmd = SqlBuilder.Insert("WeedDir") .Column("Pid", o.Pid) .Column("Name", o.Name) .Column("Depth", o.Depth) .Column("Badge", o.Badge ?? string.Empty) .Column("Extra", o.Extra ?? string.Empty) .Column("UserId", o.UserId) .Column("Status", o.Status) .Column("CreatedBy", o.CreatedBy ?? string.Empty) .Column("CreatedOn", o.CreatedOn) .Column("ModifiedBy", o.ModifiedBy ?? string.Empty) .Column("ModifiedOn", o.ModifiedOn) .ToCommand(true); return WeedConn.ExecuteScalar <int>(cmd); })); }