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); }
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)); }
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)); }