public void SendSMS(int recipientType, string recipient, int?carrier, string text) { text = text.Trim(); if (text.Length < 2) { throw new Exception("Mensaje muy corto"); } else { using (Data.DataContext DataContext = new Data.DataContext(System.Configuration.ConfigurationManager.ConnectionStrings["SMSServiceConnectionString"].ConnectionString)) { switch (recipientType) { case 2: /* Usuario */ var user = (from r in DataContext.SSO_Users where r.id == int.Parse(recipient) && r.mobile != null && r.idCarrier != null select new { r.name, r.surname, r.mobile, r.idCarrier }).SingleOrDefault(); if (user != null) { recipient = user.mobile; carrier = user.idCarrier; } else { recipient = null; } break; case 3: /* Paciente */ throw new NotImplementedException(); } if (!String.IsNullOrEmpty(recipient) && carrier.HasValue) { SSOHelper.SendSMS(recipient, carrier.Value, text); } } } }