Exemplo n.º 1
0
        private bool Validate(Sms.Domain.Sms sms)
        {
            var repository = new Sms.Data.Repository.Repository(new dbSMSContext());

            string CountryCode       = sms.to.Substring(1, 2);
            string MobileCountryCode = sms.to.Substring(3, 3);

            return(repository.IsCountryAndMobileCodeValid(CountryCode, MobileCountryCode));
        }
Exemplo n.º 2
0
        public Status SendSMS(Sms.Domain.Sms sms)
        {
            var sender = new SmsSender();

            Status status = sender.send(sms);

            RegisterSmsTransaction(sms, status);

            return(status);
        }
Exemplo n.º 3
0
        private Status SendSMS(string from, string to, string text)
        {
            var sms = new Sms.Domain.Sms()
            {
                from = from, to = to, text = text
            };

            var repository = new Repository(new dbSMSContext());

            return(repository.SendSMS(sms));
        }
Exemplo n.º 4
0
        public Status send(Sms.Domain.Sms sms)
        {
            if (!Validate(sms))
            {
                return(Status.Failed);
            }

            _serviceLocator = new ServiceLocator();
            _serviceLocator.Register <ISmsSender>(() => (new SmsService()));

            var smsFacade = new SmsFacade(_serviceLocator);

            return(smsFacade.Process(sms));
        }
Exemplo n.º 5
0
        public void RegisterSmsTransaction(Sms.Domain.Sms sms, Status status)
        {
            string CountryCode       = sms.to.Substring(1, 2);
            string MobileCountryCode = sms.to.Substring(3, 3);

            SmsTransaction tran = new SmsTransaction();

            tran.DateTransaction = DateTime.Now;
            tran.From            = sms.from;
            tran.to                = sms.to;
            tran.message           = sms.text;
            tran.Status            = status == Status.Success ? true : false;
            tran.MobileCountryCode = MobileCountryCode;
            tran.SmsPrice          = GetActualPriceFromCountryAndMobileCode(CountryCode, MobileCountryCode);

            _context.SmsTransactions.Add(tran);
            _context.SaveChanges();
        }
Exemplo n.º 6
0
        public Status Process(Sms sms)
        {
            var sender = this.serviceLocator.Resolve <ISmsSender>();

            return(sender.SendSms(sms));
        }