public async Task <AddCustomSkinResponse> Handle(AddCustomSkinRequest request, CancellationToken cancellationToken) { using (var _ = premiumCreditsDatabaseRestorePoint.CreateRestoreParams( new PremiumCreditsDatabaseRestoreParams(PremiumConstants.AddCustomSkinCost, httpContextReader.CurrentUserId))) { return(await premiumAccountManager.AddCustomSkin(request.SkinFile, request.SkinId, request.CharacterId) ? (AddCustomSkinResponse) new AddCustomSkinResponse().LogInformation( $"user #{httpContextReader.CurrentUserId} has added skin file " + $"for character #{request.CharacterId} with price {PremiumConstants.AddCustomSkinCost}") : throw new PremiumOperationException("Adding custom skin failed")); } }
public async Task <TransferCharacterResponse> Handle(TransferCharacterRequest request, CancellationToken cancellationToken) { using (var _ = premiumCreditsDatabaseRestorePoint.CreateRestoreParams( new PremiumCreditsDatabaseRestoreParams(PremiumConstants.TransferCharacterCost, httpContextReader.CurrentUserId))) { return(await premiumAccountManager.TransferCharacter(request.SourceCharacterId, request.TargetCharacterId) ? (TransferCharacterResponse) new TransferCharacterResponse() .LogInformation($"user #{httpContextReader.CurrentUserId} " + $"has transferred items from character #{request.SourceCharacterId} " + $"to character #{request.TargetCharacterId}") : throw new PremiumOperationException( $"Premium operation of transfering character from character #{request.SourceCharacterId} to character #{request.TargetCharacterId} failed")); } }
public async Task <AddSerialSlotResponse> Handle(AddSerialSlotRequest request, CancellationToken cancellationToken) { using (var _ = premiumCreditsDatabaseRestorePoint.CreateRestoreParams( new PremiumCreditsDatabaseRestoreParams(PremiumConstants.AddSerialSlotCost * request.Amount, httpContextReader.CurrentUserId)) .EnqueueToConnectionDatabaseRestorePoints(httpContextReader.ConnectionId)) { var addSerialSlotResult = await premiumAccountManager.AddSerialSlot(request) ?? throw new PremiumOperationException( "Premium operation of adding serial slot failed"); return(addSerialSlotResult.IsSucceeded ? (AddSerialSlotResponse) new AddSerialSlotResponse { CurrentSerialsLimit = addSerialSlotResult.CurrentSerialsLimit } .LogInformation( $"{(request.Amount == 1 ? "Serial slot has" : $"{request.Amount} Serial slots have")} " + $"been added to user #{httpContextReader.CurrentUserId} with price: {request.Amount * PremiumConstants.AddSerialSlotCost}") : throw new PremiumOperationException("Premium operation of adding serial slot failed")); }
public async Task <AddObjectProtectionResponse> Handle(AddObjectProtectionRequest request, CancellationToken cancellationToken) { using (var _ = premiumCreditsDatabaseRestorePoint.CreateRestoreParams( new PremiumCreditsDatabaseRestoreParams(PremiumConstants.AddObjectProtectionCost * request.Amount, httpContextReader.CurrentUserId))) { var objectProtectionResult = await premiumAccountManager.AddObjectProtection(request) ?? throw new PremiumOperationException( "Premium operation of adding object protection failed"); return(objectProtectionResult.IsSucceeded ? (AddObjectProtectionResponse) new AddObjectProtectionResponse { ProtectionType = objectProtectionResult.ProtectionType, ObjectId = objectProtectionResult.ObjectId, ProtectedUntil = objectProtectionResult.ProtectedUntil }.LogInformation( $"Protection has been added to object #{request.ObjectId} " + $"by user #{httpContextReader.CurrentUserId} with price: {request.Amount * PremiumConstants.AddObjectProtectionCost} " + $"for {request.Amount} days") : throw new PremiumOperationException("Premium operation of adding object protection failed")); } }