/// <summary> /// Handles the specified command. /// </summary> /// <param name="command">The command.</param> public void Handle(EbayRegisterCustomerCommand command) { //validates market place InfoAccumulator info = MarketPlaceQueries.ValidateCustomerMarketPlace(EbayInternalId, command.MarketplaceName); if (info.HasErrors) { SendReply(info, command); return; } int marketPlaceId = MarketPlaceQueries.GetMarketPlaceIdFromTypeId(EbayInternalId) .GetValue(); CustomerMarketPlace marketPlace = new CustomerMarketPlace { CustomerId = int.Parse(EncryptionUtils.SafeDecrypt(command.CustomerId)), DisplayName = command.MarketplaceName, MarketPlaceId = marketPlaceId, SecurityData = SerializationUtils.SerializeToBinaryXml(new EbaySecurityInfo { Token = command.Token }) }; int marketPlaceTableId = GetIdIfValidOrThrowException(MarketPlaceQueries.UpsertMarketPlace(marketPlace, EbayInternalId), marketplaceUpsertFailed); var updateHistory = new CustomerMarketPlaceUpdateHistory() { CustomerMarketPlaceId = marketPlaceTableId, UpdatingStart = DateTime.UtcNow }; int marketPlaceHistoryId = GetIdIfValidOrThrowException(MarketPlaceQueries.UpsertMarketPlaceUpdatingHistory(updateHistory) .Value, marketplaceHistoryUpsertFailed); var validateUserAccountCommand = new EbayValidationCommand(); validateUserAccountCommand.IsValidateUserAccount = true; validateUserAccountCommand.Token = command.Token; validateUserAccountCommand.PayLoad = new Dictionary <string, object> { { CustomerId, command.CustomerId }, { SessionId, command.SessionId }, { MarketplaceId, marketPlaceId }, { MarketPlaceUpdatingHistoryId, marketPlaceHistoryId } }; //sends command to validate user account //the response to this command is handled in this class by another handler method with appropriate response class SendCommand(ThirdPartyService.Address, validateUserAccountCommand, command); }
/// <summary> /// Handles the specified command. /// </summary> /// <param name="command">The command.</param> public async void Handle(EbayValidationCommand command) { InfoAccumulator info = new InfoAccumulator(); if (string.IsNullOrEmpty(command.Token)) { string msg = "got empty token"; info.AddError(msg); Log.Error(msg); SendReply(info, command); //send reply with error return; } if (command.IsValidateUserAccount.IsTrue()) { bool isAccountValid = await EBayService.ValidateAccount(command.Token); SendReply(info, command, resp => { resp.IsAccountValid = isAccountValid; resp.Token = command.Token; resp.Payload = command.PayLoad; //returns payload }); } }