示例#1
0
        public ActionResult Send(string message, IEnumerable <long> parent, bool use_email, bool use_SMS)
        {
            if (parent == null)
            {
                return(Json("No parent/guardian was specified".ToJsonFail()));
            }
            var viewmodel = new NotificationSendViewModel();

            viewmodel.message = message;

            var parentsList = new List <user>();

            foreach (var p in parent)
            {
                var usrparent = repository.GetUser(p);
                if (usrparent == null)
                {
                    return(SendJsonErrorResponse("Could not locate parent"));
                }

                if (use_email && string.IsNullOrEmpty(usrparent.email))
                {
                    return(SendJsonErrorResponse("A parent has no email address. Notification not sent."));
                }

                if (use_SMS && string.IsNullOrEmpty(usrparent.phone_cell))
                {
                    return(SendJsonErrorResponse("A parent has no cell phone number. Notification not sent."));
                }
                parentsList.Add(usrparent);
            }

            foreach (var entry in parentsList)
            {
                if (use_email)
                {
                    viewmodel.receiver = entry.ToName();
                    this.SendEmailNow(
                        EmailViewType.PARENT_NOTIFICATION,
                        viewmodel,
                        " School Attendance Info",
                        entry.email,
                        viewmodel.receiver);
                }

                if (use_SMS)
                {
                    Clickatell.Send(message, entry.phone_cell);
                }
            }

            return(Json("Notification sent successfully".ToJsonOKMessage()));
        }
示例#2
0
        public ActionResult TestSMS()
        {
            Clickatell.Send("yippeeeeee", "0165760616");

            return(Content("done"));
        }
示例#3
0
 private Microsoft.VisualStudio.Modeling.ModelElement GetParentForClickatell(Clickatell childElement)
 {
     return childElement.SubProcess;
 }
示例#4
0
        public ActionResult Send(long studentid, string message, IEnumerable <long> parent, bool use_email, bool use_SMS)
        {
            if (parent == null)
            {
                return(Json("No parent/guardian was specified".ToJsonFail()));
            }

            // get headmaster/headmistress emails to CC
            var year     = DateTime.Now.Year;
            var schoolid =
                repository.GetUser(studentid).classes_students_allocateds.Where(x => x.year == year).Select(
                    x => x.school_class.schoolid).FirstOrDefault();
            var admins = repository.GetUsers(null, null, schoolid, null, UserGroup.HEAD, null, null, null, year, null);
            var cclist = admins.Select(x => x.email);

            var viewmodel = new NotificationSendViewModel();

            viewmodel.message = message;

            var parentsList = new List <user>();

            foreach (var p in parent)
            {
                var usrparent = repository.GetUser(p);
                if (usrparent == null)
                {
                    return(SendJsonErrorResponse("Could not locate parent"));
                }

                if (use_email && string.IsNullOrEmpty(usrparent.email))
                {
                    return(SendJsonErrorResponse("A parent has no email address. Notification not sent."));
                }

                if (use_SMS && string.IsNullOrEmpty(usrparent.phone_cell))
                {
                    return(SendJsonErrorResponse("A parent has no cell phone number. Notification not sent."));
                }
                parentsList.Add(usrparent);
            }

            foreach (var entry in parentsList)
            {
                if (use_email)
                {
                    viewmodel.receiver = entry.ToName();
                    this.SendEmailNow(
                        EmailViewType.PARENT_NOTIFICATION,
                        viewmodel,
                        " School Student Conduct Info",
                        entry.email,
                        viewmodel.receiver, "", cclist);
                }

                if (use_SMS)
                {
                    Clickatell.Send(message, entry.phone_cell);

                    foreach (var number in admins.Select(x => x.phone_cell))
                    {
                        if (!string.IsNullOrEmpty(number))
                        {
                            Clickatell.Send(message, number);
                        }
                    }
                }
            }

            return(Json("Notification sent successfully".ToJsonOKMessage()));
        }