/// <summary> /// 映射 /// </summary> /// <param name="a"></param> /// <returns></returns> private ResourceCatalogInfo ToResourceCatalogInfo(Base_Catalog c) { ResourceCatalogInfo d = new ResourceCatalogInfo(); d.Id = c.Id; d.ParentId = (c.ParentId == null) ? 0 : c.ParentId.Value; d.Name = c.Name; d.OwnerId = c.OwnerId; d.OwnerType = d.OwnerType; return(d); }
///<summary> ///增加目录 ///修改:[2017-01-17/汪敏] ///</summary> ///<param name="pId">新增的目录的父Id</param> ///<param name="catalogName">新增目录的名称</param> public JsonResult CreateCatalog(string catalogName, int pId) { var catalog = new ResourceCatalogInfo(); if (pId == 0) { pId = _resourceFileService.GetFileCatalogRootId(); } catalog.ParentId = pId; catalog.Name = catalogName; catalog.OwnerId = int.Parse(User.Identity.GetUserId()); //UserId catalog.OwnerType = CommonModels.Articles.CatalogOwnerType.User; //本应该从前台传过来 return(Json(_resourceFileService.SaveCatalog(catalog), JsonRequestBehavior.AllowGet)); }
/// <summary> /// 更新一个目录对象 /// </summary> /// <param name="ResourceCatalogInfo">目录</param> /// <returns></returns> public ResourceCatalogInfo UpdateCatalog(ResourceCatalogInfo info) { Base_Catalog c = Catalog.GetById(info.Id); if (c == null) { return(null); } c.ParentId = info.ParentId; c.Name = info.Name; Base_Catalog c2 = Catalog.Save(c); var returnInfo = ToResourceCatalogInfo(c2); return(returnInfo); }
/// <summary> /// 保存一个目录对象 /// </summary> /// <param name="ResourceCatalogInfo">目录</param> /// <returns></returns> public ResourceCatalogInfo SaveCatalog(ResourceCatalogInfo info) { Base_Catalog c = new Base_Catalog { Name = info.Name, Ord = 1, State = ArticleState.Static, EditTime = TimeHelper.ServerTime, OwnerId = info.OwnerId, OwnerType = info.OwnerType }; if (info.ParentId > 0) { c.ParentId = info.ParentId; } Base_Catalog c2 = Catalog.Save(c); var returnInfo = ToResourceCatalogInfo(c2); return(returnInfo); }