Example #1
0
        public ActionResult AddSubject(int subject, List <int> categoryId, string topicName, string description)
        {
            InviteModel newInvite = new InviteModel();

            newInvite.TeacherId = null;
            newInvite.StudentId = User.Identity.GetUserId();
            newInvite.Type      = 1;
            newInvite.SubjectId = Convert.ToInt32(subject);

            int token = newInvite.Save();

            if (token == -55)
            {
                throw new HttpException(404, "Some description");
            }
            else
            {
                ResearchTopics topic = new ResearchTopics();
                topic.Topic            = topicName;
                topic.SubjectId        = subject;
                topic.ShortDescription = description;
                topic.UserId           = User.Identity.GetUserId();
                topic.ResearchIds      = categoryId;
                topic.Save();
                foreach (int id in categoryId)
                {
                    MailSender(id, subject);
                }
            }
            return(null);
        }
Example #2
0
        public ActionResult SendRequestTeacher(string tId, string subId)
        {
            //Notif part via email
            //collect the link and send it via email
            //save request row in db without approved generate token
            InviteModel newInvite = new InviteModel();

            newInvite.StudentId = tId;
            newInvite.TeacherId = User.Identity.GetUserId();
            newInvite.Type      = 0;
            newInvite.SubjectId = Convert.ToInt32(subId);
            int token = newInvite.Save();

            if (token == -55)
            {
                throw new HttpException(404, "Some description");
            }
            string link = string.Format("<p style=\"color:red\">New request pending</p><a href=\"{0}/Manage/Requests?t={1}\">{0}/Manage/Requests?t={1}</a>", Request.Url.Authority, token.ToString());

            SendMailModel.SendMail(UserManager.FindByIdAsync(tId).Result.Email, link, "SortIt. New Request");
            return(RedirectToAction("Action"));
        }