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)); }
public Status SendSMS(Sms.Domain.Sms sms) { var sender = new SmsSender(); Status status = sender.send(sms); RegisterSmsTransaction(sms, status); return(status); }
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)); }
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)); }
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(); }
public Status Process(Sms sms) { var sender = this.serviceLocator.Resolve <ISmsSender>(); return(sender.SendSms(sms)); }