// // GET: /Aviso/Create public ActionResult Create() { var avisos = unitOfWork.AvisoRepository.GetAll().ToList(); Aviso aviso = new Aviso() { Created = DateTime.Now, Publish = DateTime.Now }; CreatePageAvisos model = new CreatePageAvisos() { Avisos = avisos, Aviso = aviso}; return View(model); }
public ActionResult Create(Aviso aviso) { if (ModelState.IsValid) { unitOfWork.AvisoRepository.Add(aviso); unitOfWork.Save(); if (aviso.SendSMS) { SendSMS(aviso); } return RedirectToAction("Index"); } return View(aviso); }
private void SendSMS(Aviso aviso) { var twilio = new TwilioRestClient("AC8f7b487b784a61eb3f7e0441cf64c664", "be52390895ffefb6ad26ad94a40f9d85"); var phones = unitOfWork.AvisoRepository.GetAllContacts().Select(c => c.Phone).Distinct(); foreach (var phone in phones) { var msg = twilio.SendSmsMessage("+17732426982", "+1" + phone, aviso.Type.ToString().ToUpper() + ": " + aviso.Text); } }
public ActionResult Edit(Aviso aviso) { if (ModelState.IsValid) { unitOfWork.AvisoRepository.Update(aviso); return RedirectToAction("Index"); } return View(aviso); }