Пример #1
0
        // Submit Message
        public void submitMessage(string _subject, string _message, List <string> _tutees)
        {
            if (_subject != string.Empty && _subject != null && _message != string.Empty && _message != null)
            {
                UserDetails _user = (UserDetails)HttpContext.Current.Session["User"];
                string      _date = DateTime.Now.ToString("yyy-MM-dd");
                string      _time = DateTime.Now.ToString("hh:mm:ss");
                MessageView.error = string.Empty;
                MessageView.error = "Please be patient whilst the system sends the appropriate notification emails.";

                if (_user.UserType == 1)
                {
                    UserDetails _tutor = model.selectUserDetailsById(_user.SupervisorID);
                    model.insertMessage(_subject, _message, _user.UserID, _tutor.UserID, _date, _time);
                    general_functions.Instance.email(_tutor.EmailAddress, "You have received a message from one of your tutees (" + _user.UserID + ").\n Please Log into the eTutor system to view it.\n- eTutor System", "eTutor:- You have received a message!");
                    MessageView.resetMessageView();
                    loadMessageView();
                }
                else if (_user.UserType == 2)
                {
                    foreach (string _tutee in _tutees)
                    {
                        UserDetails _student = model.selectUserDetailsById(_tutee);
                        model.insertMessage(_subject, _message, _user.UserID, _student.UserID, _date, _time);
                        general_functions.Instance.email(_student.EmailAddress, "You have received a message from your tutor (" + _user.UserID + ").\n Please Log into the eTutor system to view it.\n\n- eTutor System", "eTutor:- You have received a message!");
                    }

                    if (_tutees.Count == 1)
                    {
                        MessageView.resetMessageView();
                        loadMessageView();
                    }
                    else
                    {
                        MessageView.resetGroupMessageView();
                        MessageView.error = "Group Message Sent Successfully!";
                    }
                }
            }
            else
            {
                MessageView.error = "Please ensure the 'Subject' and 'Message' fields are completed before submitting your message.";
            }
        }