public async Task CheckValidityAsync(CallContext callContext) { QueryValidationHelper.CheckNotReservedGuid(CurrentUserId); QueryValidationHelper.CheckNotReservedGuid(DeckId); QueryValidationHelper.CheckNotReservedGuid(CardId); await QueryValidationHelper.CheckUserIsOwnerOfDeckAsync(callContext.DbContext, CurrentUserId, DeckId); }
public async Task CheckValidityAsync(CallContext context) { QueryValidationHelper.CheckNotReservedGuid(CurrentUserId); QueryValidationHelper.CheckNotReservedGuid(CardId); await QueryValidationHelper.CheckCardExistsAsync(context.DbContext, CardId); CardVisibilityHelper.CheckUserIsAllowedToViewCards(context.DbContext, CurrentUserId, CardId); }
public async Task CheckValidityAsync(CallContext callContext) { QueryValidationHelper.CheckNotReservedGuid(DeckId); if (TargetHeap < CardInDeck.UnknownHeap || TargetHeap > CardInDeck.MaxHeapValue) { throw new InvalidOperationException($"Invalid target heap {TargetHeap}"); } await QueryValidationHelper.CheckUserIsOwnerOfDeckAsync(callContext.DbContext, UserId, DeckId); }
public async Task CheckValidityAsync(CallContext callContext) { QueryValidationHelper.CheckNotReservedGuid(UserId); var user = await callContext.DbContext.Users.SingleAsync(u => u.Id == UserId); if (!await callContext.RoleChecker.UserIsAdminAsync(user)) { throw new InvalidOperationException($"User not admin: {user.UserName}"); } }
public async Task CheckValidityAsync(CallContext callContext) { QueryValidationHelper.CheckNotReservedGuid(CurrentUserId); QueryValidationHelper.CheckNotReservedGuid(DeckId); QueryValidationHelper.CheckContainsNoReservedGuid(ExcludedCardIds); QueryValidationHelper.CheckContainsNoReservedGuid(ExcludedTagIds); if (CardsToDownload < 1 || CardsToDownload > 100) { throw new RequestInputException($"Invalid CardsToDownload: {CardsToDownload}"); } await QueryValidationHelper.CheckUserIsOwnerOfDeckAsync(callContext.DbContext, CurrentUserId, DeckId); }
public async Task CheckValidityAsync(CallContext callContext) { QueryValidationHelper.CheckNotReservedGuid(UserId); if (CardIds.Any(cardId => QueryValidationHelper.IsReservedGuid(cardId))) { throw new RequestInputException($"Invalid card id"); } foreach (var cardId in CardIds) { CardVisibilityHelper.CheckUserIsAllowedToViewCards(callContext.DbContext, UserId, cardId); } await Task.CompletedTask; }
public async Task CheckValidityAsync(CallContext callContext) { QueryValidationHelper.CheckNotReservedGuid(UserId); QueryValidationHelper.CheckNotReservedGuid(SubscriptionId); var subscription = await callContext.DbContext.SearchSubscriptions.Where(s => s.Id == SubscriptionId).SingleOrDefaultAsync(); if (subscription == null) { throw new RequestInputException("Subscription not found"); } if (subscription.UserId != UserId) { throw new RequestInputException("User not owner of subscription"); } }
public async Task CheckValidityAsync(CallContext callContext) { //We allow viewing the history of a card as soon as the user can access the current version of the card. Of course the differ will refuse to give details to a user not allowed QueryValidationHelper.CheckNotReservedGuid(UserId); QueryValidationHelper.CheckNotReservedGuid(CardId); var user = await callContext.DbContext.Users.SingleAsync(u => u.Id == UserId); var card = await callContext.DbContext.Cards.Include(v => v.UsersWithView).SingleAsync(v => v.Id == CardId); if (!CardVisibilityHelper.CardIsVisibleToUser(UserId, card.UsersWithView)) { throw new InvalidOperationException("Current not visible to user"); } }
public async Task CheckValidityAsync(CallContext callContext) { QueryValidationHelper.CheckNotReservedGuid(UserId); if (PageSize < 1 || PageSize > MaxPageSize) { throw new InvalidOperationException($"Invalid page size: {PageSize}"); } if (PageNo < 1) { throw new InvalidOperationException($"Invalid page index: {PageNo}"); } var user = await callContext.DbContext.Users.SingleAsync(u => u.Id == UserId); if (!await callContext.RoleChecker.UserIsAdminAsync(user)) { throw new InvalidOperationException($"User not admin: {user.UserName}"); } }
public async Task CheckValidityAsync(CallContext callContext) { QueryValidationHelper.CheckNotReservedGuid(UserId); QueryValidationHelper.CheckNotReservedGuid(SubscriptionId); if (Name.Length < MinNameLength) { throw new RequestInputException($"Name '{Name}' is too short, must be between {MinNameLength} and {MaxNameLength} chars long, is {Name.Length}"); } if (Name.Length > MaxNameLength) { throw new RequestInputException($"Name '{Name}' is too long, must be between {MinNameLength} and {MaxNameLength} chars long, is {Name.Length}"); } var subscription = await callContext.DbContext.SearchSubscriptions.Where(s => s.Id == SubscriptionId).SingleOrDefaultAsync(); if (subscription == null) { throw new RequestInputException("Subscription not found"); } if (subscription.UserId != UserId) { throw new RequestInputException("User not owner of subscription"); } }
public async Task CheckValidityAsync(CallContext callContext) { QueryValidationHelper.CheckNotReservedGuid(TagId); await Task.CompletedTask; }