public async Task DeleteWishlistItemAsync(WishlistItemDto wishlistItemDto) { try { var wishlistItem = new WishlistItem(wishlistItemDto); await _wishlistRepository.DeleteWishlistItemAsync(wishlistItem); } catch (Exception e) { _logger.LogError(e, "Exception while deleting wishlist item."); throw; } }
public async Task UpdateWishlistItemDescriptionAsync(WishlistItemDto wishlistItemDto) { try { var wishlistItem = new WishlistItem(wishlistItemDto); await _wishlistRepository.UpdateWishlistItemDescriptionAsync(wishlistItem); } catch (Exception e) { _logger.LogError(e, "Exception while updating description on wishlist item."); throw; } }
public async Task UpdateWishlistItemClaimAsync(WishlistItemDto wishlistItemDto, string currentUserId, bool isClaim) { try { var wishlistItem = new WishlistItem() { Id = wishlistItemDto.Id, UserId = wishlistItemDto.UserId }; await _wishlistRepository.UpdateWishlistItemClaimAsync(wishlistItem, currentUserId, isClaim); } catch (Exception e) { _logger.LogError(e, "Exception while updating claim on wishlist item."); throw new WishlistDbException("An unknown error occurred."); } }
public async Task <IActionResult> DeleteWishlistItem(string personId, WishlistItemDto wishlistItem) { if (personId != wishlistItem.UserId) { return(BadRequest()); } var authResult = await _authorizationService.AuthorizeAsync(User, personId, Operation.AddEditDeleteWishlistItem); if (!authResult.IsAuthorised) { return(Forbid()); } await _wishlistService.DeleteWishlistItemAsync(wishlistItem); return(NoContent()); }
public async Task <IActionResult> AddWishlistItem(string personId, WishlistItemDto wishlistItem) { if (personId != wishlistItem.UserId) { return(BadRequest()); } var authResult = await _authorizationService.AuthorizeAsync(User, personId, Operation.AddEditDeleteWishlistItem); if (!authResult.IsAuthorised) { return(Forbid()); } var result = await _wishlistService.AddWishlistItemAsync(wishlistItem); return(CreatedAtAction(nameof(GetWishlist), new { personId, result.Id }, result)); }
public async Task <IActionResult> UnclaimWishlistItem(string personId, WishlistItemDto wishlistItem) { if (personId != wishlistItem.UserId) { return(BadRequest()); } var authResult = await _authorizationService.AuthorizeAsync(User, personId, Operation.ClaimOrUnclaimWishlistItem); if (!authResult.IsAuthorised) { return(Forbid()); } await _wishlistService.UpdateWishlistItemClaimAsync(wishlistItem, authResult.Person.Id, false); return(Ok()); }
public async Task <WishlistItemDto> AddWishlistItemAsync(WishlistItemDto wishlistItemDto) { try { var wishlistItem = new WishlistItem(wishlistItemDto.UserId, wishlistItemDto.Description); var createdWishlistItem = await _wishlistRepository.AddWishlistItemAsync(wishlistItem); return(new WishlistItemDto { Id = createdWishlistItem.Id, Description = createdWishlistItem.Description, UserId = createdWishlistItem.UserId, IsClaimable = false, IsClaimedByMe = false }); } catch (Exception e) { _logger.LogError(e, "Exception while adding wishlist item."); throw; } }