Ejemplo n.º 1
0
        private DateTime _GetRandomSubmissionDelayForSubscriber(Domain.Subscriber subscriber)
        {
            var localStartTime = subscriber.TimeWindowStart.ToLocalTime();
            var localEndTime   = subscriber.TimeWindowEnd.ToLocalTime();
            var submitDateTime = DateTime.Today.Date.Add(localStartTime.TimeOfDay);

            if (submitDateTime < DateTime.Now)
            {
                submitDateTime = submitDateTime.AddDays(1);
            }

            var startTimeSpan = localStartTime.TimeOfDay;
            var endTimeSpan   = localEndTime.TimeOfDay;

            if (endTimeSpan < startTimeSpan)
            {
                endTimeSpan = endTimeSpan.Add(new TimeSpan(1, 0, 0, 0));
            }

            var timeDiff      = endTimeSpan.Subtract(startTimeSpan);
            var randomSeconds = new Random().Next((int)timeDiff.TotalSeconds);
            var result        = submitDateTime.AddSeconds(randomSeconds);

            return(result);
        }
Ejemplo n.º 2
0
 public static Subscriber TranslateToSubscriber(Domain.Subscriber source)
 {
     return(new Subscriber
     {
         Id = source.Id,
         TimeWindowEnd = source.TimeWindowEnd,
         TimeWindowStart = source.TimeWindowStart,
         FirstName = source.FirstName,
         Phone = source.Phone
     });
 }
Ejemplo n.º 3
0
        private async Task <Submission> _CreateSubmission(Domain.Subscriber subscriber, Domain.Affirmation[] affirmations)
        {
            var submission = new Domain.Submission
            {
                Subscriber     = subscriber,
                Affirmation    = _SelectRandom(affirmations),
                SubmissionTime = _GetRandomSubmissionDelayForSubscriber(subscriber).ToUniversalTime()
            };

            await mDomainContext.AddSubmission(submission);

            var result = Translation.CoreTranslator.TranslateToSubmission(submission);

            return(result);
        }