Esempio n. 1
0
        private async Task <bool> CountCheckAsync <T>(string userId, IQueryable <T> query, int?maxCount)
        {
            if (maxCount == null || await premiumProvider.HasPremiumAsync(userId))
            {
                return(true);
            }

            int count = await query.CountAsync();

            return(maxCount > count);
        }
Esempio n. 2
0
        public async Task <IActionResult> GetYearList(int year)
        {
            string userId = HttpContext.User.FindUserId();

            if (string.IsNullOrEmpty(userId))
            {
                return(Unauthorized());
            }

            if (!await premiumProvider.HasPremiumAsync(userId))
            {
                return(PremiumRequired());
            }

            var result = await shareStatus
                         .OwnedByOrExplicitlySharedWithUser(dataContext, dataContext.Entries, userId)
                         .Where(e => e.When.Year == year)
                         .OrderByDescending(e => e.When)
                         .Select(e => new CalendarEntryModel()
            {
                Id    = e.Id,
                Title = e.Title,
                When  = e.When
            })
                         .AsNoTracking()
                         .ToListAsync();

            return(Ok(result));
        }
Esempio n. 3
0
        protected override async Task <bool> IsValidSizeAsync(string userId, long fileLength)
        {
            if (configuration.PremiumMaxLength != null)
            {
                bool hasPremium = await premiumProvider.HasPremiumAsync(userId);

                if (hasPremium)
                {
                    return(fileLength <= configuration.PremiumMaxLength.Value);
                }
            }

            return(await base.IsValidSizeAsync(userId, fileLength));
        }