public ScheduleMessageResponse Handle(ScheduleMessageRequest request) { var message = new Message() { Content = request.MessageContent, DateTimeToSend = request.DateTimeToSend, CommunityId = request.CommunityId }; message = _messages.Create(message); var phoneNumbers = _communities .Get(request.CommunityId) .Subscribers .ToList(); var jobId = _scheduler.Schedule( () => phoneNumbers.ForEach( phoneNumber => _sms.SendMessageAsync( message, phoneNumber)), request.DateTimeToSend); message.JobId = jobId; _messages.Update(message); return(new ScheduleMessageResponse()); }
public SendMessageResponse Handle(SendMessageRequest request) { _messages.Create(request.Message); var phoneNumbers = _communities .Get(request.Message.CommunityId) .Subscribers .ToList(); phoneNumbers.ForEach(phoneNumber => _sms.SendMessageAsync(request.Message, phoneNumber) ); return(new SendMessageResponse()); }