public ActionResult CreateMessageToVolunteersByDisaster(int id)
 {
     var model = new SendMessageToAllVolunteersByDisasterViewModel { DisasterId = id };
     PopulateSendMessageViewModel(model);
     // Default subject to disaster name so they can type just a message if they want to.
     model.Subject = model.DisasterName;
     return View("CreateMessage", model);
 }
Exemplo n.º 2
0
        public ActionResult SendMessageToVolunteersByDisaster(SendMessageToAllVolunteersByDisasterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                PopulateSendMessageViewModel(model);
                return View("CreateMessage", model);
            }
            var recipientCriterion = new RecipientCriterion(model.DisasterId, model.ClusterId);
            var message = new Message(model.Subject, model.Message);
            _messageSvc.SendMessageToDisasterVolunteers(recipientCriterion, message);

            return View(model);
        }
        public ActionResult SendMessageToVolunteersByDisaster(SendMessageToAllVolunteersByDisasterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                PopulateSendMessageViewModel(model);
                return View("CreateMessage", model);
            }
            var sender = model.DisasterName + " - Coordinator";
            var recipientCriterion = new RecipientCriterion(model.DisasterId, model.ClusterId, model.ClusterCoordinatorsOnly, model.CheckedInOnly);
            var message = new Message(model.Subject, model.Message);
            _messageSvc.SendMessageToDisasterVolunteers(message, recipientCriterion, sender);

            return View(model);
        }
        public ActionResult SendMessageToVolunteersByDisaster(SendMessageToAllVolunteersByDisasterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                PopulateSendMessageViewModel(model);
                return View("CreateMessage", model);
            }
            else if (model.IsSMSMessage && model.Message.Length > Constants.TwilioMessageLength)
            {
                PopulateSendMessageViewModel(model);
                ModelState["Message"].Errors.Add(string.Format("The message cannot have more than {0} characters when submiting as a SMS.", Constants.TwilioMessageLength));
                return View("CreateMessage", model);
            }

            var sender = model.DisasterName + " - Coordinator";
            var recipientCriterion = new RecipientCriterion(model.DisasterId, model.SelectedClusterIds, model.ClusterCoordinatorsOnly, model.CheckedInOnly);
            var message = new Message(model.Subject, model.Message) { IsSMSMessage = model.IsSMSMessage };

            _messageSvc.SendMessageToDisasterVolunteers(message, recipientCriterion, sender);

            return View(model);
        }
 private void PopulateSendMessageViewModel(SendMessageToAllVolunteersByDisasterViewModel model)
 {
     model.DisasterName = _disasterSvc.GetName(model.DisasterId);
     model.Clusters = _clusterSvc.GetList();
 }