/// <summary> /// Handles the specified command. /// </summary> /// <param name="command">The command.</param> public void Handle(CustomerLoginCommand command) { InfoAccumulator info = new InfoAccumulator(); bool res = CustomerQueries.IsUserExists(command.EmailAddress, EncryptPassword(command.Password)); if (!res) { Log.ErrorFormat("Could not find user. EmailAddress: {0}, Password: {1}"); info.AddError("User does not exists."); SendReply(info, command); return; } Customer customer = CustomerQueries.GetCustomerPartiallyByProperty(where => where.Name, command.EmailAddress, select => select.Id); if (customer == null) { Log.ErrorFormat("We have a security user with email: {0}, but do not have a customer with this email"); info.AddError("Server error"); RegisterError(info, command); SendReply(info, command); return; } SendReply(info, command, resp => resp.CustomerId = CustomerIdEncryptor.EncryptCustomerId(customer.Id, command.CommandOriginator)); }
/// <summary> /// Validates the mobile phone number. /// </summary> /// <param name="phoneNumber">The phone number.</param> /// <param name="code">The code.</param> /// <returns></returns> public InfoAccumulator ValidateMobilePhoneNumber(string phoneNumber, string code) { InfoAccumulator errors = new InfoAccumulator(); if (string.IsNullOrEmpty(phoneNumber)) { String errorMsg = "got empty phone number"; Log.Error(errorMsg); errors.AddError(errorMsg); return(errors); } if (string.IsNullOrEmpty(code)) { String errorMsg = "got empty code"; Log.Error(errorMsg); errors.AddError(errorMsg); return(errors); } if (!MobilePhoneQueries.ValidateMobilePhoneNumber(phoneNumber, code)) { String errorMsg = String.Format("failed to validate phone number: {0} and code: {1}", phoneNumber, code); Log.Warn(errorMsg); errors.AddInfo(errorMsg); } return(errors); }
/// <summary> /// Gets the ids. /// </summary> /// <param name="command">The command.</param> /// <param name="customerId">The customer identifier.</param> /// <param name="info">The information.</param> /// <param name="companyId">The company identifier.</param> /// <returns></returns> private bool GetIds(UpdateCompanyCommand command, InfoAccumulator info, out int customerId, out int companyId) { DateTime date; try { customerId = CustomerIdEncryptor.DecryptCustomerId(command.CustomerId, command.RequestOrigin, out date); } catch (Exception ex) { Log.Error(ex.Message); info.AddError("Invalid customer id."); customerId = -1; companyId = -1; return(false); } try { companyId = CompanyIdEncryptor.DecryptCompanyId(command.CustomerId, command.RequestOrigin, out date); } catch (Exception ex) { Log.Error(ex.Message); info.AddError("Invalid company id."); customerId = -1; companyId = -1; return(false); } return(true); }
/// <summary> /// Handles the specified command. /// </summary> /// <param name="command">The command.</param> public async void Handle(TwilioSendSmsCommand command) { InfoAccumulator info = new InfoAccumulator(); TwilioSms sms = null; if (string.IsNullOrEmpty(command.Message) || string.IsNullOrEmpty(command.PhoneNumber)) { info.AddError("got empty message or phone number"); } else { Message response = await Twilio.SendSms(command.PhoneNumber, command.Message); if (response == null) { info.AddError("error in sending sms"); } else { sms = GetTwilioSms(response); } } SendReply(info, command, resp => resp.Sms = sms); }
/// <summary> /// Handles the specified request. /// </summary> /// <param name="command">The request.</param> public async void Handle(CustomerSendVerificationSmsCommand command) { string verificationWord = StringUtils.GenerateRandomEnglishString(); TwilioSendSmsCommand sendSmsCommand = CreateSendSmsCommand(command, verificationWord); InfoAccumulator info = new InfoAccumulator(); try { var response = await TwilioSmsAsyncSendReceive.SendAsync(Config.Address, sendSmsCommand); if (response.Sms != null) { response.Sms.UserId = int.Parse(EncryptionUtils.SafeDecrypt(command.CustomerId)); MobilePhoneQueries.SaveTwilioSms(response.Sms); } else { info.AddError("error sending sms"); } SendReply(info, command); } catch (TaskCanceledException ex) { Log.Error("Time out on sending sms"); info.AddError("Time out sending sms"); SendReply(info, command); } }
/// <summary> /// Handles the specified command. /// </summary> /// <param name="command">The command.</param> public void Handle(DocsUploadCommand command) { InfoAccumulator info = new InfoAccumulator(); int customerId; try { customerId = CustomerIdEncryptor.DecryptCustomerId(command.CustomerId, command.CommandOriginator); } catch (Exception ex) { Log.Error(ex.Message); info.AddError("Invalid customer id."); SendReply(info, command, resp => resp.CustomerId = command.CustomerId); return; } var fileMetaData = command.Files.Select(path => ConvertToFileMetadata(path, command.IsBankDocuments, customerId)); bool res = DocsUploadQueries.SaveCompanyUploadedFiles(fileMetaData); if (!res) { string error = string.Format("could not save some or all uploaded files for customer: {0}", command.CustomerId); info.AddError(error); RegisterError(info, command); throw new Exception("Failed to save some files");//we want to retry } SendReply(info, command, resp => resp.CustomerId = command.CustomerId); }
/// <summary> /// Validates the signup command. /// </summary> /// <param name="command">The command.</param> /// <returns></returns> private InfoAccumulator ValidateSignupCommand(CustomerSignupCommand command) { InfoAccumulator info = new InfoAccumulator(); if (command.EmailAddress.IsEmpty()) { info.AddError("Got empty email address."); } if (command.Password.IsEmpty()) { info.AddError("Got empty password."); } if (command.SequrityQuestionId.HasValue) { if (command.SequrityQuestionId.Value < 1 || command.SequrityQuestionId > 3) { info.AddError("Invalid security question id"); } else if (command.SecurityQuestionAnswer.IsEmpty()) { info.AddError("Empty security question"); } } return(info); }
public void NSBTest() { //initiates structure map container IContainer container = InitContainer(typeof(CustomerProcessor)); InfoAccumulator acc = new InfoAccumulator(); acc.AddError("error1"); acc.AddError("error2"); acc.AddException(new InvalidOperationException("bla bla bla")); string json = JsonConvert.SerializeObject(acc); var info = JsonConvert.DeserializeObject(json, typeof(InfoAccumulator)); container = new Container(new EzBobServiceRegistry()); Context context = new Context(); Scenario.Define(context) .WithEndpoint <EzBobService>(b => { b.Given((bus, ctx) => { bus.Send <CustomerSignupCommand>("EzBobService2", m => { m.MessageId = Guid.NewGuid(); }); SubscriptionForIncomingBehavior.OnEndpointSubscribed(s => { int kk = 0; }); OutgoingSubscription.OnEndpointSubscribed(s => { int kk = 0; }); }) .When(ctx => ctx.IsServiceReady, bus => bus.Send <CustomerSignupCommand>("EzBobService2", m => { m.MessageId = Guid.NewGuid(); })); }) .Done(IsDone) .Run(); // // Scenario.Define(ctx) // .WithEndpoint<EzBobService>(c => c.CustomConfig(cfg => cfg // .UseContainer(CreateNsbTestContainer(container)) //based on initialized container, creates container suitable for NSB test framework // ) // .Given((bus, context) => SubscriptionForIncomingBehavior.OnEndpointSubscribed(s => { // int kk = 0; // })) // .When(context => context.IsMaySignup, bus => bus.Send("EzBobService2", new CustomerSignupCommand()))) // .Done(IsDone) // .Run(); }
/// <summary> /// Sends the SMS and if sent saves it in DB. /// </summary> /// <param name="phoneNumber">The phone number.</param> /// <param name="message">The message.</param> /// <param name="country">The country.</param> /// <param name="errors">The errors.</param> /// <returns></returns> private async Task <bool> SendSmsAndSave(string phoneNumber, string message, CountryName country, InfoAccumulator errors) { //validate phone number if (string.IsNullOrEmpty(phoneNumber)) { String errorMessage = "attempt to send sms to an empty phone number"; Log.Error(errorMessage); errors.AddError(errorMessage); return(false); } //validate debug mode if (IsInDebugMode(phoneNumber)) { return(true); } string toPhoneNumber = NormalizePhoneNumber(phoneNumber, country); //validate message if (string.IsNullOrEmpty(message)) { errors.AddInfo("not sending empty message"); Log.Warn("attempt to send empty message to phone number: " + toPhoneNumber + " . SMS was not send"); return(false); } Log.InfoFormat("Sending sms to phone number: {0}, message: {1}", toPhoneNumber, message); //send sms TwilioSendSmsCommandResponse twilioResponse = await TwilioSmsSender.SendAsync(ThirdPartyService.Address, new TwilioSendSmsCommand { Message = message, PhoneNumber = toPhoneNumber }); if (twilioResponse.Sms == null) { return(false); } //save sms in DB if (!MobilePhoneQueries.SaveTwilioSms(twilioResponse.Sms)) { string errorMsg = String.Format("Failed to save Twilio SMS response to DB: {0}", message); Log.Error(errorMsg); errors.AddError(errorMsg); return(false); } return(true); }
private string ExtractTaxOfficeNumber(HtmlDocument doc, InfoAccumulator info) { const string sBaseXPath = "//dl[contains(@class, 'known-facts')]"; HtmlNodeCollection dataLists = doc.DocumentNode.SelectNodes(sBaseXPath); if (dataLists == null) { Log.Warn("No suitable location for Tax Office Number found."); return(null); } // if foreach (HtmlNode dl in dataLists) { HtmlNode dt = dl.SelectSingleNode("./dt"); if (dt == null) { continue; } if (dt.InnerText != "Tax Office Number:") { continue; } HtmlNode dd = dl.SelectSingleNode("./dd"); if (dd == null) { info.AddError("Tax Office Number not found."); return(null); } var taxOfficeNumber = dd.InnerText.Trim().Replace(" ", ""); if (taxOfficeNumber == string.Empty) { info.AddError("Tax Office Number not specified."); return(null); } Log.InfoFormat("Tax office number is {0}.", taxOfficeNumber); return(taxOfficeNumber); } // for each data list info.AddWarning("Tax Office Number location not found."); Log.Warn("Tax Office Number location not found."); return(null); } // ExtractTaxOfficeNumber
/// <summary> /// Handles the specified command. /// </summary> /// <param name="cmd">The command.</param> /// <exception cref="System.IO.InvalidDataException"></exception> public void Handle(YodleeAddUserAccountCommand cmd) { InfoAccumulator info = new InfoAccumulator(); if (YodleeQueries.IsUserAlreadyHaveContentService(cmd.CustomerId, cmd.ContentServiceId)) { string msg = "the customer already added this content service" + cmd.ContentServiceId; info.AddError(msg); Log.Info(msg); SendReply(info, cmd); return; } var siteId = YodleeQueries.GetSiteIdFromContentServiceId(cmd.ContentServiceId); if (!siteId.HasValue) { string err = "could not retrieve site id from DB"; Log.Error(err); info.AddError(err); RegisterError(info, cmd); //go to retry throw new InvalidDataException(err); } var yodleeUserAccount = YodleeQueries.GetUserAccount(cmd.CustomerId); if (yodleeUserAccount == null) { var err = "could not get user account from DB for id: " + cmd.CustomerId; Log.Error(err); info.AddError(err); RegisterError(info, cmd); //go to retry throw new InvalidDataException(err); } YodleeGetFastLinkCommand fastLinkCommand = new YodleeGetFastLinkCommand { ContentServiceId = cmd.ContentServiceId, CobrandUserName = Config.CoBrandUserName, CobrandPassword = Config.CoBrandPassword, UserName = yodleeUserAccount.Username, UserPassword = yodleeUserAccount.Password, SiteId = siteId.Value }; SendCommand(ThirdPartyConfig.Address, fastLinkCommand, cmd); }
/// <summary> /// Validates the specified model. /// </summary> /// <param name="model">The model.</param> /// <param name="errors">The errors.</param> /// <param name="isToValidateProperty">The is to validate property.</param> /// <returns></returns> protected bool ValidateModel(object model, InfoAccumulator errors, Func <string, bool> isToValidateProperty = null) { bool res = true; if (model == null) { errors.AddError("got empty model"); return(false); } if (isToValidateProperty == null) { isToValidateProperty = s => true; } PropertyInfo[] propertyInfos = model.GetType() .GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (var propertyInfo in propertyInfos.Where(prop => prop.CanWrite && prop.CanRead)) { if (!isToValidateProperty(propertyInfo.Name)) { continue; } object propertyValue = propertyInfo.GetValue(model); if (propertyValue == null) { string error = "could not obtain " + model.GetType() .Name + "'s " + propertyInfo.Name; errors.AddError(error); Log.Error(error); res = false; } else if (propertyInfo.PropertyType == typeof(string) && string.IsNullOrEmpty((string)propertyValue)) { string error = "could not obtain " + model.GetType() .Name + "'s " + propertyInfo.Name; errors.AddError(error); Log.Error(error); res = false; } } return(res); }
/// <summary> /// Handles the specified command. /// </summary> /// <param name="cmd">The command.</param> public void Handle(YodleeUserAddedAccountCommand cmd) { InfoAccumulator info = new InfoAccumulator(); var userAccount = YodleeQueries.GetUserAccount(cmd.CustomerId); if (userAccount == null) { string err = "could not get useraccount from db for id: " + cmd.CustomerId; info.AddError(err); Log.Error(err); RegisterError(info, cmd); //go to retry throw new InvalidDataException(err); } YodleeGetUserAccountsCommand userAccountsCommand = new YodleeGetUserAccountsCommand { UserName = userAccount.Username, UserPassword = userAccount.Password, CobrandUserName = Config.CoBrandUserName, CobrandPassword = Config.CoBrandPassword, CustomerId = cmd.CustomerId }; SendCommand(ThirdPartyService.Address, userAccountsCommand, cmd); }
/// <summary> /// Handles the specified response. /// </summary> /// <param name="response">The response.</param> public void Handle(YodleeGetUserAccountsCommandResponse response) { if (response.IsFailed) { ReplyToOrigin(response); return; } var existingContentServicesIds = YodleeQueries.GetUserContentServicesIds(response.CustomerId) .ToLookup(o => o); List <YodleeContentServiceAccount> newAccounts = response.Accounts.Where(o => !existingContentServicesIds.Contains(o.ContentServiceId)) .ToList(); if (newAccounts.Count > 0) { InfoAccumulator info = new InfoAccumulator(); info.AddInfo("customer " + response.CustomerId + "added " + newAccounts.Count + " accounts"); SaveAccounts(newAccounts, response.UserName, response.UserPassword); SendTransactionsRequestCommand(newAccounts, response.UserName, response.UserPassword); SendReply(info, response); } else { InfoAccumulator info = new InfoAccumulator(); info.AddError("could not find added account for customer: " + response.CustomerId); SendReply(info, response); } }
public void Handle(CustomerGetDetailsCommand command) { InfoAccumulator info = new InfoAccumulator(); int customerId; try { customerId = CustomerIdEncryptor.DecryptCustomerId(command.CustomerId, command.CommandOriginator); } catch (Exception ex) { Log.Error(ex.Message); info.AddError("Invalid customer id."); SendReply(info, command); return; } Customer customer = CustomerQueries.GetCustomerById(customerId); IEnumerable <CustomerAddress> addresses = CustomerQueries.GetCustomerAddresses(customerId); IEnumerable <CustomerPhone> phones = CustomerQueries.GetCustomerPhones(customerId); var requesetedLoan = LoanQueries.GetCustomerRequestedLoan(customerId); SendReply(info, command, resp => { resp.PersonalDetails = GetPersonalDetails(customer); resp.ContactDetails = GetContactDetails(phones, customer); resp.CurrentLivingAddress = GetCurrentLivingAddress(addresses, customer); resp.PreviousLivingAddress = GetPreviousLivingAddress(addresses, customer); resp.AdditionalOwnedProperties = GetAdditionalOwnedProperties(addresses, customer) .ToArray(); resp.RequestedAmount = (decimal)requesetedLoan.Map(o => o.Amount.HasValue ? o.Amount.Value : 0); }); }
/// <summary> /// Handles the CustomerSignupCommand. /// </summary> /// <param name="command">The command.</param> public void Handle(CustomerSignupCommand command) { InfoAccumulator info = ValidateSignupCommand(command); if (info.HasErrors) { SendReply(info, command); return; } //TODO: code below contains race condition. We should find a way to validate to do it properly if (!BrokerQueries.IsExistsBroker(command.EmailAddress)) { Log.ErrorFormat("Attempt to sign in customer with email of broker: {0}", command.EmailAddress); info.AddError("Sign-up error"); SendReply(info, command); return; } SecurityUser user; try { user = CustomerQueries.CreateSecurityUser(command.EmailAddress, command.Password, command.SequrityQuestionId ?? 0, command.SecurityQuestionAnswer, command.CommandOriginatorIP); } catch (SqlException ex) { Log.ErrorFormat("Attempt to sign in existing customer: {0}", command.EmailAddress); info.AddError("Sign-up error"); SendReply(info, command); return; } Customer customer = ConvertToCustomer(command, user); int id = (int)CustomerQueries.UpsertCustomer(customer); if (id < 1) { Log.ErrorFormat("could not create customer of user: "******"could not create customer"); } string encryptedCustomerId = CustomerIdEncryptor.EncryptCustomerId(customer.Id, command.CommandOriginator); SendReply(info, command, response => response.CustomerId = encryptedCustomerId); }
/// <summary> /// Handles a message. /// </summary> /// <param name="command">The command to handle.</param> /// <remarks> /// This method will be called when a message arrives on the bus and should contain /// the custom logic to execute when the command is received. /// </remarks> public void Handle(CustomerUpdateCommand command) { InfoAccumulator info = new InfoAccumulator(); if (!ValidateCommand(command, info)) { SendReply(info, command, response => response.CustomerId = command.CustomerId); return; } int customerId; try { customerId = CustomerIdEncryptor.DecryptCustomerId(command.CustomerId, command.CommandOriginator); } catch (Exception ex) { Log.Error(ex.Message); info.AddError("Invalid customer id."); SendReply(info, command, resp => resp.CustomerId = command.CustomerId); return; } //requests only PropertyStatusId from DB Customer customer = CustomerQueries.GetCustomerPartiallyById(customerId, o => o.PropertyStatusId); FillCustomerProperties(customer, command, info); if (info.HasErrors) { SendReply(info, command, resp => resp.CustomerId = command.CustomerId); return; } IEnumerable <CustomerAddress> addresses = FillCustomerPropertyStatusAndTimeAtAddressAndGetAddresses(command, customer, customerId); IEnumerable <CustomerPhone> phones = ExtractPhoneNumbers(command, customerId); string referenceSource = null; string visitTimes = null; if (command.Cookies != null) { referenceSource = command.Cookies.ReferenceSource; visitTimes = command.Cookies.VisitTimes; } var errors = CustomerProcessor.UpdateCustomer(customer, command.RequestedAmount, referenceSource, visitTimes, command.CampaignSourceRef, addresses, phones); if (errors.HasErrors) { if (errors.IsRetry) { RegisterError(info, command); } return; } SendReply(errors, command, response => response.CustomerId = command.CustomerId); }
/// <summary> /// Validates user name and password. /// </summary> /// <param name="userName">Name of the user.</param> /// <param name="password">The password.</param> /// <returns></returns> private InfoAccumulator ValidateUserNamePassword(string userName, string password) { InfoAccumulator info = new InfoAccumulator(); if (string.IsNullOrEmpty(userName)) { Log.Error("empty user name"); info.AddError("empty user name"); } if (string.IsNullOrEmpty(password)) { Log.Error("empty password"); info.AddError("empty password"); } return(info); }
/// <summary> /// Validates the command. /// </summary> /// <param name="command">The command.</param> /// <param name="info">The information.</param> /// <returns></returns> private bool ValidateCommand(UpdateCompanyCommand command, InfoAccumulator info) { if (StringUtils.IsEmpty(command.CustomerId)) { info.AddError("invalid customer id"); return(false); } return(true); }
/// <summary> /// Saves the generated code and phone number. /// </summary> /// <param name="phoneNumber">The phone number.</param> /// <param name="code">The code.</param> /// <param name="errors">The errors.</param> /// <returns></returns> private bool SaveGeneratedCodeAndPhoneNumber(string phoneNumber, string code, InfoAccumulator errors) { if (!MobilePhoneQueries.StoreMobilePhoneAndCode(phoneNumber, code)) { errors.AddError("could not save mobile phone and code"); return(false); } return(true); }
/// <summary> /// Returns the error. /// </summary> /// <param name="errorMessage">The error message.</param> /// <returns></returns> private HmrcVatReturnsInfo ReturnError(string errorMessage) { InfoAccumulator info = new InfoAccumulator(); info.AddError(errorMessage); Log.Error(errorMessage); return(new HmrcVatReturnsInfo { Info = info }); }
} // ExtractTaxOfficeNumber /// <summary> /// Gets the user vat identifier new fashioned way. /// </summary> /// <param name="doc">The document.</param> /// <param name="info">The information.</param> /// <returns></returns> private string GetUserVatIdNewFashionedWay(HtmlDocument doc, InfoAccumulator info) { HtmlNode section = doc.DocumentNode.SelectSingleNode("//section[@id=\"section-vat\"]"); if (section == null) { info.AddError("VAT section not found (new fashion way)."); return(null); } // if if (!section.HasChildNodes) { info.AddError("VAT section is empty (new fashion way)."); return(null); } // if HtmlNode para = section.Element("p"); if (para == null) { info.AddError("VAT id location not found (new fashion way)."); return(null); } // if string innerText = (para.InnerText ?? string.Empty); if (!innerText.StartsWith("VAT registration number")) { info.AddError("Failed to parse VAT id location (new fashion way)."); return(null); } // if string id = innerText.Substring(innerText.IndexOf(':') + 1).Trim(); if (string.IsNullOrEmpty(id)) { info.AddError("Could not extract user VAT id in a new fashion way."); return(null); } // if return(id); } // GetUserVatIDNewFashionWay
/// <summary> /// Determines whether we can generate code and send SMS by examining count information. /// </summary> /// <param name="countInfo">The count information.</param> /// <param name="mobilePhoneNumber">The mobile phone number.</param> /// <param name="errors">The errors.</param> /// <returns></returns> private bool CanGenerateCodeAndSendSms(CountInfo countInfo, string mobilePhoneNumber, InfoAccumulator errors) { if (Config.MaxPerDay <= countInfo.SentToday) { string errorMsg = string.Format("Reached max number of daily SMS messages ({0}). SMS not sent", Config.MaxPerDay); errors.AddError(errorMsg); Log.Error(errorMsg); return(false); } if (Config.MaxPerNumber <= countInfo.SentToNumber) { string errorMsg = string.Format("Reached max number of SMS messages ({0}) to number:{1}. SMS not sent", Config.MaxPerNumber, mobilePhoneNumber); errors.AddError(errorMsg); Log.Error(errorMsg); return(false); } return(true); }
/// <summary> /// Validates the specified command. /// </summary> /// <param name="command">The command.</param> /// <returns></returns> private InfoAccumulator Validate(HmrcProcessUploadedFilesCommand command) { InfoAccumulator info = new InfoAccumulator(); if (CollectionUtils.IsEmpty(command.Files)) { info.AddError("no files to parse"); } return(info); }
/// <summary> /// Handles the specified command. /// </summary> /// <param name="command">The command.</param> public void Handle(CustomerValidateVerificationCodeCommand command) { InfoAccumulator info = new InfoAccumulator(); bool isValid = VerificationHelper.Validate(command.VerificationCode, command.VerificationToken); if (!isValid) { Log.Info("Invalid verification code"); info.AddError("Invalid verification code"); } SendReply(info, command, resp => resp.CustomerId = command.CustomerId); }
} // GetUserVatIDNewFashionWay /// <summary> /// Gets the user vat identifier in old fashioned way. /// </summary> /// <param name="doc">The document.</param> /// <returns></returns> private string GetUserVatIdOldFashionedWay(HtmlDocument doc, InfoAccumulator info) { HtmlNode link = doc.DocumentNode.SelectSingleNode("//a[@id=\"LinkAccessVAT\"]") ?? doc.DocumentNode.SelectSingleNode("//a[@id=\"LinkAccessVATMakeVATReturn\"]"); if (link == null) { info.AddError("Access VAT services link not found (old fashioned way)."); return(null); } if (!link.Attributes.Contains(Href)) { info.AddError("Access VAT services link has no HREF attribute (old fashioned way)."); return(null); } string href = link.Attributes[Href].Value; if (!href.StartsWith("/vat/trader/")) { info.AddError("Failed to parse Access VAT services link (old fashioned way)."); return(null); } string id = href.Substring(href.LastIndexOf('/') + 1).Trim(); if (string.IsNullOrEmpty(id)) { info.AddError("Could not extract user VAT id in an old fashioned way."); return(null); } // if return(id); } // GetUserVatIDOldFashionWay
/// <summary> /// Handles the specified command. /// </summary> /// <param name="command">The command.</param> public async void Handle(SimplyPostcodeGetAddresses3dPartyCommand command) { InfoAccumulator info = new InfoAccumulator(); SimplyPostCodeAddressSearchResponse response = await SimplyPostcodeService.GetAddressesByPostCode(command.PostCode); if (StringUtils.IsNotEmpty(response.errorMessage)) { info.AddError(response.errorMessage); SendReply(info, command); return; } SendReply(info, command, resp => resp.Addresses = response.Records); }
/// <summary> /// Validates the customer market place. /// </summary> /// <param name="marketPlaceTypeId">The market place type identifier.</param> /// <param name="displayName">The display name.</param> /// <returns></returns> public InfoAccumulator ValidateCustomerMarketPlace(Guid marketPlaceTypeId, string displayName) { InfoAccumulator info = new InfoAccumulator(); if (!IsMarketPlaceInWhiteList(marketPlaceTypeId, displayName)) { if (IsMarketPlaceExists(marketPlaceTypeId, displayName)) { string msg = string.Format("the market place with name: '{0}' already exists", displayName); info.AddError(msg); } } return(info); }
/// <summary> /// Validates the specified command. /// </summary> /// <param name="command">The command.</param> /// <returns></returns> private InfoAccumulator Validate(HmrcRegisterCustomerCommand command) { InfoAccumulator info = new InfoAccumulator(); if (string.IsNullOrEmpty(command.CustomerId)) { Log.Info(emptyCustomerID); info.AddError(emptyCustomerID); } if (string.IsNullOrEmpty(command.UserName)) { Log.Info(emptyUserName); info.AddError(emptyUserName); } if (string.IsNullOrEmpty(command.Password)) { Log.Info(emptyPassword); info.AddError(emptyPassword); } return(info); }
/// <summary> /// Gets the ids. /// </summary> /// <param name="command">The command.</param> /// <param name="info">The information.</param> /// <param name="customerId">The customer identifier.</param> /// <param name="companyId">The company identifier.</param> /// <param name="authorityId">The authority identifier.</param> /// <returns></returns> private bool GetIds(CompanyUpdateAuthorityCommand command, InfoAccumulator info, out int customerId, out int companyId, ref int authorityId) { try { customerId = CustomerIdEncryptor.DecryptCustomerId(command.CustomerId, command.CommandOriginator); companyId = CompanyIdEncryptor.DecryptCompanyId(command.CompanyId, command.CommandOriginator); if (command.AuhorityId.IsNotEmpty()) { authorityId = AuthorityIdEncryptor.DecryptAuthorityId(command.AuhorityId, command.CommandOriginator, command.Authority.IsDirector); } } catch (Exception ex) { Log.Error(ex.Message); info.AddError(ex.Message); customerId = -1; companyId = -1; return(false); } return(true); }