Exemplo n.º 1
0
        public void OnHomeWorkCreateHandler(HomeWork homeWork)
        {
            MailSender mailSender = new MailSender();

            string subject = "Home work: " + homeWork.Title + " is created";
            string text    = "Student: " + homeWork.Student + " has created home work: " + homeWork.Title;

            bool mailSent = mailSender.Send(Email, subject, text);
        }
Exemplo n.º 2
0
        public void OnHomeWorkChangeStatusHandler(HomeWork homeWork, HomeWorkStatus prevStatus, HomeWorkStatus newStatus)
        {
            MailSender mailSender = new MailSender();

            string subject = "Home work: " + homeWork.Title + " changed status";
            string text    = "Teacher: " + homeWork.board.Teacher + " has changed home work status:\n"
                             + "previos status: " + prevStatus + "\n"
                             + "new status: " + newStatus;

            bool mailSent = mailSender.Send(Email, subject, text);
        }
Exemplo n.º 3
0
        public override List <HomeWork> GetHomeWorks(Repository repository)
        {
            List <HomeWork> HomeWorks = new List <HomeWork>();

            XmlElement root = GetRootNodeFromXML();

            foreach (XmlNode dataNode in root.ChildNodes)
            {
                if (dataNode.Name == "HomeWorks")
                {
                    foreach (XmlNode node in dataNode.ChildNodes)
                    {
                        int     hwId     = 0;
                        XmlNode attrHwId = node.Attributes.GetNamedItem("id");
                        if (attrHwId != null)
                        {
                            int.TryParse(attrHwId.Value, out hwId);
                        }

                        string  hwTitle   = "";
                        XmlNode attrTitle = node.Attributes.GetNamedItem("title");
                        if (attrTitle != null)
                        {
                            hwTitle = attrTitle.Value;
                        }

                        int     boardId     = 0;
                        XmlNode attrboardId = node.Attributes.GetNamedItem("boardId");
                        if (attrHwId != null)
                        {
                            int.TryParse(attrboardId.Value, out boardId);
                        }

                        string  hwText     = "";
                        XmlNode attrHwText = node.Attributes.GetNamedItem("text");
                        if (attrHwText != null)
                        {
                            hwText = attrHwText.Value;
                        }

                        string  hwComment     = "";
                        XmlNode attrHwComment = node.Attributes.GetNamedItem("comment");
                        if (attrHwComment != null)
                        {
                            hwComment = attrHwComment.Value;
                        }

                        HomeWorkStatus hwStatus     = HomeWorkStatus.ToDo;
                        int            hwStatusId   = 0;
                        XmlNode        attrHwStatus = node.Attributes.GetNamedItem("status");
                        if (attrHwStatus != null)
                        {
                            int.TryParse(attrHwStatus.Value, out hwStatusId);
                            hwStatus = (HomeWorkStatus)Enum.GetValues(typeof(HomeWorkStatus)).GetValue(hwStatusId - 1);
                        }

                        Person  student       = null;
                        XmlNode attrStudentId = node.Attributes.GetNamedItem("studentId");
                        if (attrStudentId != null)
                        {
                            int hwStudentId = 0;
                            int.TryParse(attrStudentId.Value, out hwStudentId);
                            student = repository.Persons.Get(hwStudentId);
                        }

                        DateTime createDateHomeWork = new DateTime(1, 1, 1);
                        XmlNode  attrHwCreateDate   = node.Attributes.GetNamedItem("createDate");
                        if (attrHwCreateDate != null)
                        {
                            DateTime.TryParse(attrHwCreateDate.Value, out createDateHomeWork);
                        }

                        Board board = repository.Boards.Get(boardId);

                        if (hwId != 0 && hwTitle != "" && student != null && board != null)
                        {
                            HomeWork HW = new HomeWork(board,
                                                       hwTitle,
                                                       hwText,
                                                       hwComment,
                                                       student,
                                                       hwStatus,
                                                       hwId,
                                                       createDateHomeWork);
                            board.HomeWorkList.Add(HW);

                            HomeWorks.Add(HW);
                        }
                    }
                    break;
                }
            }

            return(HomeWorks);
        }