using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; //using System.Web.Mvc; using Song.Entities; using Song.ServiceInterfaces; using Song.ViewData.Attri; using WeiSha.Common; using System.Data; namespace Song.ViewData.Methods { /// /// 专业管理 /// [HttpGet] public class Subject : IViewAPI { /// /// 通过专业ID,获取专业信息 /// /// 专业id /// public Song.Entities.Subject ForID(int id) { Song.Entities.Subject sbj = Business.Do().SubjectSingle(id); return _tran(sbj); } /// /// 某个机构下的专业 /// /// 机构id /// 专业列表 public Song.Entities.Subject[] List(int orgid) { Song.Entities.Subject[] sbjs = Business.Do().SubjectCount(orgid, string.Empty, true, -1, -1); for (int i = 0; i < sbjs.Length; i++) { sbjs[i] = _tran(sbjs[i]); } return sbjs; } /// /// 某个机构下的专业 /// /// 机构id /// 专业列表 public DataTable Tree(int orgid) { Song.Entities.Subject[] sbjs= Business.Do().SubjectCount(orgid, string.Empty, true, -1, -1); for (int i = 0; i < sbjs.Length; i++) { sbjs[i] = _tran(sbjs[i]); } DataTable dt = WeiSha.WebControl.Tree.ObjectArrayToDataTable.To(sbjs); WeiSha.WebControl.Tree.DataTableTree tree = new WeiSha.WebControl.Tree.DataTableTree(); tree.IdKeyName = "Sbj_ID"; tree.ParentIdKeyName = "Sbj_PID"; tree.TaxKeyName = "Sbj_Tax"; tree.Root = 0; dt = tree.BuilderTree(dt); return dt; } #region 私有方法,处理对象的关联信息 /// /// 处理专业信息,图片转为全路径,并生成clone对象 /// /// 专业对象的clone /// private Song.Entities.Subject _tran(Song.Entities.Subject sbj) { if (sbj == null) return sbj; Song.Entities.Subject clone = sbj.Clone(); clone.Sbj_Logo = WeiSha.Common.Upload.Get["Subject"].Virtual + clone.Sbj_Logo; clone.Sbj_LogoSmall = WeiSha.Common.Upload.Get["Subject"].Virtual + clone.Sbj_LogoSmall; return clone; } #endregion } }