using Furion.DependencyInjection; using RoadFlow.Utility; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RoadFlow.Data { public class Applibrary:RoadFlowRepository,IApplibrary, ITransient { /// /// 根据Code得到实体 /// /// /// public Model.rf_applibrary GetByCode(string code) { List appLibraries = GetAll(); return appLibraries.Find(p => p.Code.EqualsIgnoreCase(code)); } /// /// 删除应用 /// /// /// public int Delete(string id) { var app = GetOneById(id); return null == app ? 0 : Delete(app); } /// /// 得到对应语言的标题 /// /// /// 语言 /// public string GetLanguageTitle(Model.rf_applibrary appLibrary, string language = "") { if (null == appLibrary) { return string.Empty; } string lang = language.IsNullOrWhiteSpace() ? Tools.GetCurrentLanguage() : language; switch (lang) { case "en-US": return appLibrary.Title_en; case "zh": return appLibrary.Title_zh; default: return appLibrary.Title; } } /// /// 得到一个类别的应用 /// /// 类别ID /// public List GetListByType(string typeId) { List appLibraries = new List(); var all = GetAll(); var typeIds = new Dictionary().GetAllChildsId(typeId); foreach (var id in typeIds) { appLibraries.AddRange(all.FindAll(p => p.Type == id)); } return appLibraries.OrderBy(p => p.Title).ToList(); } } }