Exemplo n.º 1
0
        public static AtomCateConfigModel GetAllById(int relId)
        {
            var result = new AtomCateConfigModel();

            result.Children = new List <AtomCateConfigModel>();
            var now = DateTime.Now;

            var cates = SonFact.Cur.FindMany <AtomConfigValue, AtomConfigValueModel>(t => t.IsValid == true && (t.RelId == relId || t.ValueType == "default"));

            foreach (var item in cates)
            {
                if (item.StartTime != null && item.StartTime.Value > now)
                {
                    continue;
                }
                if (item.EndTime != null && item.EndTime.Value < now)
                {
                    continue;
                }
                result.Values.Add(item);
            }

            var cateCodes = cates.Select(t => t.CateCode).Distinct();

            foreach (var c in cateCodes)
            {
                var vs = Get(relId, c);
                result.Children.Add(vs);
            }
            return(result);
        }
Exemplo n.º 2
0
        public static AtomCateConfigModel Get(int relId, string cateCode)
        {
            var result = new AtomCateConfigModel();

            result.Values = new List <AtomConfigValueModel>();
            var now  = DateTime.Now;
            var list = SonFact.Cur.FindMany <AtomConfigValue, AtomConfigValueModel>(t => t.IsValid == true && t.CateCode == cateCode && (t.RelId == relId || t.ValueType == "default"));

            foreach (var item in list)
            {
                if (item.StartTime != null && item.StartTime.Value > now)
                {
                    continue;
                }
                if (item.EndTime != null && item.EndTime.Value < now)
                {
                    continue;
                }
                result.Values.Add(item);
            }
            return(result);
        }