示例#1
0
        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);
        }
示例#2
0
        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();
        }
示例#3
0
        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>();
        }