public void CountryCodeConfigSet_LeavesNumberLeadingDigitDoesntMatch() { var countryCodeReplacement = new CountryCodeReplacement { CountryCode = "+61", LeadingNumberToReplace = "0" }; const string number = "+61400000"; var cleanAndInternationaliseNumber = countryCodeReplacement.CleanAndInternationaliseNumber(number); Assert.That(cleanAndInternationaliseNumber, Is.EqualTo("+61400000")); }
public void CountryCodeConfigNotSet_LeavesNumber() { var countryCodeReplacement = new CountryCodeReplacement(); const string number = "+61400000"; var cleanAndInternationaliseNumber = countryCodeReplacement.CleanAndInternationaliseNumber(number); Assert.That(cleanAndInternationaliseNumber, Is.EqualTo(number)); }
public SendAllMessagesAtOnce MapToSendAllAtOnce(CoordinatedSharedMessageModel model, CountryCodeReplacement countryCodeReplacement, List<string> excludedNumbers) { return new SendAllMessagesAtOnce { Messages = model .GetCleanInternationalisedNumbers(countryCodeReplacement) .Where(n => !excludedNumbers.Contains(n)) .Select(n => new SmsData(n, model.Message)) .ToList(), SendTimeUtc = DateTimeOlsenMapping.DateTimeWithOlsenZoneToUtc(model.StartTime, model.UserTimeZone), MetaData = new SmsMetaData { Tags = model.GetTagList(), Topic = model.Topic }, ConfirmationEmail = model.ConfirmationEmail, ConfirmationEmails = model.GetEmailList(), UserOlsenTimeZone = model.UserTimeZone }; }
public PartialViewResult EditAjax(CountryCodeReplacement configuration) { var isValid = TryUpdateModel(configuration); if (!isValid) return PartialView("_CountryCodeConfigCreate", configuration); using (var session = DocumentStore.GetStore().OpenSession("Configuration")) { var countryCode = session.Load<CountryCodeReplacement>("CountryCodeConfig"); if (countryCode == null) { session.Store(configuration, "CountryCodeConfig"); } else { countryCode.CountryCode = configuration.CountryCode; countryCode.LeadingNumberToReplace = configuration.LeadingNumberToReplace; } session.SaveChanges(); return PartialView("_CountryCodeConfigDetails", configuration); } }
public TrickleSmsOverCalculatedIntervalsBetweenSetDates MapToTrickleOverPeriod(CoordinatedSharedMessageModel model, CountryCodeReplacement countryCodeReplacement, List<string> excludedNumbers) { return new TrickleSmsOverCalculatedIntervalsBetweenSetDates { Duration = model.SendAllBy.Value.Subtract(model.StartTime), Messages = model .GetCleanInternationalisedNumbers(countryCodeReplacement) .Where(n => !excludedNumbers.Contains(n)) .Select(n => new SmsData(n, model.Message)) .ToList(), StartTimeUtc = DateTimeOlsenMapping.DateTimeWithOlsenZoneToUtc(model.StartTime, model.UserTimeZone), // startTimeUtc,// model.StartTime.ToUniversalTime(), MetaData = new SmsMetaData { Tags = model.GetTagList(), Topic = model.Topic }, ConfirmationEmail = model.ConfirmationEmail, ConfirmationEmails = model.GetEmailList(), UserOlsenTimeZone = model.UserTimeZone }; }
public List<string> GetCleanInternationalisedNumbers(CountryCodeReplacement countryCodeReplacement) { return Numbers.Split(new[] { ',', ';', ':' }).Select(number => countryCodeReplacement != null ? countryCodeReplacement.CleanAndInternationaliseNumber(number) : number.Trim()).ToList(); }
public TrickleSmsWithDefinedTimeBetweenEachMessage MapToTrickleSpacedByPeriod(CoordinatedSharedMessageModel model, CountryCodeReplacement countryCodeReplacement, List<string> excludedNumbers) { return new TrickleSmsWithDefinedTimeBetweenEachMessage { Messages = model .GetCleanInternationalisedNumbers(countryCodeReplacement) .Where(n => !excludedNumbers.Contains(n)) .Select(n => new SmsData(n, model.Message)) .ToList(), StartTimeUtc = DateTimeOlsenMapping.DateTimeWithOlsenZoneToUtc(model.StartTime, model.UserTimeZone), TimeSpacing = TimeSpan.FromSeconds(model.TimeSeparatorSeconds.Value), MetaData = new SmsMetaData { Tags = model.GetTagList(), Topic = model.Topic }, ConfirmationEmail = model.ConfirmationEmail, ConfirmationEmails = model.GetEmailList(), UserOlsenTimeZone = model.UserTimeZone }; }
public TrickleSmsWithDefinedTimeBetweenEachMessage MapToTrickleSpacedByPeriod(CoordinatedSharedMessageModel model, CountryCodeReplacement countryCodeReplacement) { var tags = string.IsNullOrWhiteSpace(model.Tags) ? null : model.Tags.Split(',').ToList().Select(t => t.Trim()).ToList(); var rawNumberList = model.Numbers.Split(','); var cleanedInternationalisedNumbers = rawNumberList.Select(number => countryCodeReplacement != null ? countryCodeReplacement.CleanAndInternationaliseNumber(number) : number.Trim()).ToList(); return new TrickleSmsWithDefinedTimeBetweenEachMessage { Messages = cleanedInternationalisedNumbers.Select(n => new SmsData(n, model.Message)).ToList(), StartTimeUtc = model.StartTime.ToUniversalTime(), TimeSpacing = TimeSpan.FromSeconds(model.TimeSeparatorSeconds.Value), MetaData = new SmsMetaData { Tags = tags, Topic = model.Topic }, ConfirmationEmail = model.ConfirmationEmail }; }
public TrickleSmsOverCalculatedIntervalsBetweenSetDates MapToTrickleOverPeriod(CoordinatedSharedMessageModel model, CountryCodeReplacement countryCodeReplacement) { var rawNumberList = model.Numbers.Split(','); var cleanedInternationalisedNumbers = rawNumberList.Select(number => countryCodeReplacement != null ? countryCodeReplacement.CleanAndInternationaliseNumber(number) : number.Trim()).ToList(); var tags = string.IsNullOrWhiteSpace(model.Tags) ? null : model.Tags.Split(',').ToList().Select(t => t.Trim()).ToList(); return new TrickleSmsOverCalculatedIntervalsBetweenSetDates { Duration = model.SendAllBy.Value.Subtract(model.StartTime), Messages = cleanedInternationalisedNumbers .Select(n => new SmsData(n, model.Message)). ToList(), StartTimeUtc = model.StartTime.ToUniversalTime(), MetaData = new SmsMetaData { Tags = tags, Topic = model.Topic }, ConfirmationEmail = model.ConfirmationEmail }; }