Esempio n. 1
0
        public override async Task Execute()
        {
            var query = Session.Query <VisibleMaster, VisibleIndex>()
                        .Statistics(out QueryStatistics stats)
                        .Take(Filter.Take)
                        .Skip(Filter.Skip * Filter.Take)
                        .OrderByDescending(a => a.DateModified);

            if (Filter.ImageRestrict)
            {
                query = query.Where(v => v.IsImage);
            }

            if (Filter.VideoRestrict)
            {
                query = query.Where(v => v.IsVideo);
            }

            if (Filter.DocumentRestrict)
            {
                query = query.Where(v => v.IsDocument);
            }

            query = await Init(query, Filter, "visible");

            Result = await VisibleDisplayProjection.Transform(query.OfType <VisibleFile>()).ToListAsync();

            Process(Filter, stats);
        }
Esempio n. 2
0
        public override async Task Execute()
        {
            var visibleQuery = VisibleDisplayProjection
                               .Transform(Session.Query <VisibleFile, VisibleIndex>().Where(c => c.Id == Id)).Take(1).LazilyAsync();
            var favQuery = Session.Query <FavMaster, FavFanIndex>().Where(c => c.Id == Id).CountLazilyAsync();

            var visibleResult = await visibleQuery.Value;
            var favResult     = await favQuery.Value;

            Result           = visibleResult.FirstOrDefault();
            Result.Favourite = favResult > 0;
        }
Esempio n. 3
0
        public override async Task Execute()
        {
            Result = await Session.LoadAsync <Msg>(Id);

            if (Result != null)
            {
                ResultFiles = await VisibleDisplayProjection
                              .Transform(Session.Query <VisibleFile, VisibleIndex>().Where(c => c.Id.In(Result.Files)))
                              .ToListAsync();

                ResultRecipients = await ResultProfileProjection
                                   .Transform(Session.Query <UserMaster, UserIndex>().Where(c => c.Id.In(Result.Recipients))
                                              .OfType <IEntityProfile>()).ToListAsync();

                if (!string.IsNullOrEmpty(Result.ReplyId))
                {
                    ResultReply = await MsgDisplayTrans
                                  .Transform(Session.Query <MsgMaster, MsgIndex>().Where(c => c.Id == Result.ReplyId))
                                  .FirstOrDefaultAsync();
                }
            }
        }