Exemple #1
0
 //
 // 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);
 }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
            }
        }
Exemple #4
0
 public ActionResult Edit(Aviso aviso)
 {
     if (ModelState.IsValid)
     {
         unitOfWork.AvisoRepository.Update(aviso);
         return RedirectToAction("Index");
     }
     return View(aviso);
 }