public MessageStateEnum SendSms(SmsRequest sms) { var message = new AddSmsCommand(sms); _bus.Send(message); var result = _eventDal.WaitUntilAvailable(message.ID); return(result ? MessageStateEnum.Sent : MessageStateEnum.Failed); }
public void Handle(AddSmsCommand command) { var message = command.Message; var countryCode = new string(message.From.Take(2).ToArray()); var countries = _dataAccess.Value.Query <Country>().ToList(); var country = countries.FirstOrDefault(cnItem => cnItem.CountryCode == countryCode); message.CountryId = country.ID; _dataAccess.Value.AddEntity(message); _dataAccess.Value.Save(); }
public void CommandHandlerTest() { var commandHandler = Container.Resolve <SmsCommandHandler>(); var message = new SmsRequest() { From = "049985", To = "888", Text = "Hello" }; ICommand command = new AddSmsCommand(message); // commandHandler.Handle(command); Assert.IsNotNull(commandHandler); IMittoMessageDao dal = Container.Resolve <IMittoMessageDao>(); }