Beispiel #1
0
        private static List <Tuple <string, decimal> > GetCoefs(SimpleRepository context, string parentTC)
        {
            var coefs = context.Find <CourseCoef>(x => x.CourseTC == parentTC)
                        .Select(x => Tuple.Create(x.CourseTC2, x.Coef))
                        .Concat(context.Find <CourseCoef>(x => x.CourseTC2 == parentTC)
                                .Select(x => Tuple.Create(x.CourseTC, x.Coef))).ToList();

            return(coefs);
        }
Beispiel #2
0
        /// <summary>
        /// 获取推送信息
        /// </summary>
        public ActionResult All()
        {
            var number = ZNRequest.GetString("number");

            if (string.IsNullOrWhiteSpace(number))
            {
                return(Json(new { result = false, message = "" }, JsonRequestBehavior.AllowGet));
            }
            var list    = logdb.Find <PushLog>(x => x.Number == number).GroupBy(x => x.PushType).ToList();
            var newlist = (from l in list
                           select new
            {
                PushType = l.Key,
                PushCount = l.Count()
            }).ToList();

            return(Json(new { result = true, message = newlist }, JsonRequestBehavior.AllowGet));
        }
        public virtual System.Collections.Generic.IEnumerable <T> FindBy <T>(object id) where T : class, IParseData, new()
        {
            List <T>  items      = new List <T>();
            IList <T> foundItems = dataRespository.Find <T>(x => x.KeyIndex == id.ToString());

            foreach (var item in foundItems)
            {
                items.Add(item);
            }
            return(items.ToArray());
        }
Beispiel #4
0
        protected List <ArticleJson> ArticleListInfo(List <Article> list, string usernumber = "")
        {
            //文章编号集合
            var array        = list.Select(x => x.Number).ToArray();
            var articletypes = AppHelper.GetArticleType();
            var parts        = new SubSonic.Query.Select(provider).From <ArticlePart>().Where <ArticlePart>(x => x.Types == Enum_ArticlePart.Pic).And("ArticleNumber").In(array).OrderAsc("SortID").ExecuteTypedList <ArticlePart>();

            List <string> userids = new List <string>();

            list.ForEach(x =>
            {
                userids.Add(x.CreateUserNumber);
            });

            var users = new SubSonic.Query.Select(provider, "ID", "NickName", "Avatar", "Cover", "Signature", "Number", "IsPay").From <User>().Where("Number").In(userids.ToArray()).ExecuteTypedList <User>();

            //判断是否关注、判断是否点赞、判断是否收藏
            var fans  = new List <Fan>();
            var zans  = new List <ArticleZan>();
            var keeps = new List <Keep>();

            if (!string.IsNullOrWhiteSpace(usernumber))
            {
                fans  = db.Find <Fan>(x => x.CreateUserNumber == usernumber).ToList();
                zans  = db.Find <ArticleZan>(x => x.CreateUserNumber == usernumber).ToList();
                keeps = db.Find <Keep>(x => x.CreateUserNumber == usernumber).ToList();
            }

            var tags = GetTag();

            List <ArticleJson> newlist = new List <ArticleJson>();

            list.ForEach(x =>
            {
                var user = users.FirstOrDefault(y => y.Number == x.CreateUserNumber);
                if (user != null)
                {
                    ArticleJson model   = new ArticleJson();
                    var articletype     = articletypes.FirstOrDefault(y => y.ID == x.TypeID);
                    model.UserID        = user.ID;
                    model.NickName      = user.NickName;
                    model.Avatar        = user.Avatar;
                    model.Signature     = user.Signature;
                    model.UserCover     = user.Cover;
                    model.IsPay         = user.IsPay;
                    model.ArticleID     = x.ID;
                    model.ArticleNumber = x.Number;
                    model.Title         = x.Title;
                    model.Views         = x.Views;
                    model.Goods         = x.Goods;

                    //标签
                    model.TagList = new List <Tag>();
                    if (!string.IsNullOrWhiteSpace(x.Tag))
                    {
                        var tag = x.Tag.Split(',').ToList();
                        tag.ForEach(y =>
                        {
                            var id   = Tools.SafeInt(y);
                            var item = tags.FirstOrDefault(z => z.ID == id);
                            if (item != null)
                            {
                                model.TagList.Add(item);
                            }
                        });
                    }
                    model.IsFollow     = fans.Count(y => y.ToUserNumber == x.CreateUserNumber);
                    model.IsZan        = zans.Count(y => y.ArticleNumber == x.Number);
                    model.IsKeep       = keeps.Count(y => y.ArticleNumber == x.Number);
                    model.UserNumber   = x.CreateUserNumber;
                    model.Cover        = x.Cover;
                    model.CreateDate   = x.CreateDate.ToString("yyyy-MM-dd hh:mm");
                    model.TypeName     = articletype == null ? "" : articletype.Name;
                    model.ArticlePart  = parts.Where(y => y.ArticleNumber == x.Number).OrderBy(y => y.ID).Take(4).ToList();
                    model.ArticlePower = x.ArticlePower;
                    model.Recommend    = x.Recommend;
                    model.Province     = x.Province;
                    model.City         = x.City;
                    model.Submission   = x.Submission;
                    newlist.Add(model);
                }
            });

            return(newlist);
        }
        public IList <Order> SearchOrder(string imsi, List <string> targetContentId, string productCode)
        {
            var res = SimpleRepository.Find <Order>(s => s.Imsi == imsi && s.Status == OrderStatus.Successed && s.ProductCode == productCode && targetContentId.ToArray().Contains(s.TargetContentID));

            return(res);
        }