Ejemplo n.º 1
0
        public List <StudentMessageDTO> GetStudentMessagesById(int id)
        {
            List <StudentMessageDTO> studentMessages = new List <StudentMessageDTO>();

            using (officehoursEntities officeHoursDB = new officehoursEntities())
            {
                var adminUserData = from f in officeHoursDB.officehours_messages
                                    where f.message_id == id
                                    select f;

                foreach (officehours_messages usr in adminUserData)
                {
                    if (usr != null)
                    {
                        StudentMessageDTO studentMessage = new StudentMessageDTO()
                        {
                            studentName = usr.student_Name,
                            studentId   = usr.student_id,
                            DateCreated = (DateTime)usr.Date_Created,
                            facultyMail = usr.faculty_mail,
                            isArchived  = Convert.ToInt32(usr.is_archived),
                            message     = usr.message,
                            messageId   = usr.message_id
                        };

                        studentMessages.Add(studentMessage);
                    }
                }
                return(studentMessages);
            }
        }
Ejemplo n.º 2
0
        public string CreateStudentMessage(StudentMessageDTO studentMessage)
        {
            using (officehoursEntities officeHoursDB = new officehoursEntities())
            {
                officehours_messages messageData = new officehours_messages()
                {
                    faculty_mail = studentMessage.facultyMail,
                    Date_Created = DateTime.Now,
                    is_archived  = studentMessage.isArchived,
                    message      = studentMessage.message,
                    student_id   = studentMessage.studentId,
                    student_Name = studentMessage.studentName,
                    message_id   = studentMessage.messageId
                };

                officeHoursDB.officehours_messages.Add(messageData);
                try
                {
                    officeHoursDB.SaveChanges();
                    return(messageData.faculty_mail);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    return(e.Message);
                }
            }
        }
Ejemplo n.º 3
0
        public void SaveQuizAuthorResponseMessage(StudentMessageDTO token, out long emailId, out string error)
        {
            error = string.Empty;
            try
            {
                var html = GetTemplateHtml(EmailEnums.eTemplateKinds.QUIZ_AUTHOR_RESPONSE);

                var message = new EmailMessageDTO
                {
                    Subject       = String.Format(QUIZ_AUTHOR_RESPONSE_SUBJECT, token.QuizTitle)
                    , MessageFrom = FROM
                    , UserId      = CurrentUserId
                    , ToEmail     = token.Student.Email
                    , ToName      = token.Student.FullName
                    , Status      = EmailEnums.eSendInterfaceStatus.Waiting
                    , AddOn       = DateTime.Now
                    , MessageBody = html.Replace(EmailEnums.eTemplateFields.LEARNER_NAME.ToString().Field2Template(), token.Student.FullName)
                                    .Replace(EmailEnums.eTemplateFields.COURSE_AUTHOR.ToString().Field2Template(), token.Author.FullName)
                                    .Replace(EmailEnums.eTemplateFields.QUIZ_NAME.ToString().Field2Template(), token.QuizTitle)
                                    .Replace(EmailEnums.eTemplateFields.QUIZ_ATTEMPT_NO.ToString().Field2Template(), token.AvailableAttempts.ToString())
                };

                SaveMessage(message, out emailId);
            }
            catch (Exception ex)
            {
                error   = FormatError(ex);
                emailId = -1;
                Logger.Error("email service::SaveQuizAuthorResponseMessage email message", ex, CommonEnums.LoggerObjectTypes.Email);
            }
        }
Ejemplo n.º 4
0
        public void SaveQuizContactAuthorMessage(StudentMessageDTO token, out long emailId, out string error)
        {
            error = string.Empty;
            try
            {
                var html = GetTemplateHtml(EmailEnums.eTemplateKinds.QUIZ_AUTHOR_REQUEST);

                var message = new EmailMessageDTO
                {
                    Subject       = String.Format(QUIZ_CONTACT_AUTHOR_SUBJECT, token.CourseName)
                    , MessageFrom = FROM
                    , UserId      = CurrentUserId
                    , ToEmail     = token.Author.Email
                    , ToName      = token.Author.FullName
                    , Status      = EmailEnums.eSendInterfaceStatus.Waiting
                    , AddOn       = DateTime.Now
                    , MessageBody = html.Replace(EmailEnums.eTemplateFields.LEARNER_NAME.ToString().Field2Template(), token.Student.FullName)
                                    .Replace(EmailEnums.eTemplateFields.LEARNER_EMAIL.ToString().Field2Template(), "<a style=\"" + NAME_HTML_STYLE_UNDERLINE + "\"  href=\"mailto:" + token.Student.Email + "\" >" + token.Student.Email + "</a>")
                                    .Replace(EmailEnums.eTemplateFields.QUIZ_NAME.ToString().Field2Template(), token.QuizTitle)
                                    .Replace(EmailEnums.eTemplateFields.FREE_TEXT.ToString().Field2Template(), token.Message)
                };

                SaveMessage(message, out emailId);
            }
            catch (Exception ex)
            {
                error   = FormatError(ex);
                emailId = -1;
                Logger.Error("email service::SaveQuizContactAuthorMessage email message", ex, CommonEnums.LoggerObjectTypes.Email);
            }
        }
Ejemplo n.º 5
0
        public ActionResult SendMessage(StudentMessageDTO token)
        {
            string error;
            var    result = _quizWidgetServices.SendMessageToAuthor(token, CurrentUserId, out error);

            return(Json(new JsonResponseToken {
                success = result, error = error
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 6
0
        protected void createEvent_Click(object sender, EventArgs e)
        {
            StudentMessageDTO messageDTO = new StudentMessageDTO();

            messageDTO.facultyMail = Session["Email"].ToString();
            messageDTO.studentId   = txtStudId.Text;
            messageDTO.studentName = txtStudName.Text;
            messageDTO.message     = txtAppointmentDescription.Text;
            studentMessage.CreateStudentMessage(messageDTO);
            Response.Redirect("~/Views/StudentHome.aspx");
        }
Ejemplo n.º 7
0
        public static void UpdateStudentMessageDto(this StudentMessageDTO token, QZ_StudentQuizInfoToken entity)
        {
            token.QuizTitle = entity.Title;

            token.Author = new BaseUserInfoDTO
            {
                UserId     = entity.AuthorUserId
                , Email    = entity.AuthorEmail
                , FullName = entity.Entity2AuthorFullName()
            };

            token.Student = new BaseUserInfoDTO
            {
                UserId     = entity.UserId
                , Email    = entity.Email
                , FullName = entity.Entity2StudentFullName()
            };
        }
 public string CreateStudentMessage(StudentMessageDTO studentMessage)
 {
     return(studentMessageDB.CreateStudentMessage(studentMessage));
 }