コード例 #1
0
        public ActionResult SetFinalStatus(int id)
        {
            try
            {
                DissertationViewModel dissertation = Dissertation.GetDissertationById(id);
                dissertation.SaveStatus();
                Certificate cert = new Certificate();
                cert.StudentId = dissertation.StudentId;
                cert.SubjectId = dissertation.SubjectId;
                int certId = cert.Save();
                var user   = UserManager.FindById(dissertation.StudentId);
                UserManager.AddToRole(user.Id, "Teacher");
                var callbackUrl = Url.Action("Certificates", "Teacher", new { certId = certId }, protocol: Request.Url.Scheme);

                string email   = dissertation.Student.Email;
                string body    = string.Format("Dear {0} {1}, Your research was approved by administrator:</br> Follow the <a href='{2}'>link</a> to generate a certificate", dissertation.Student.Name, dissertation.Student.SurName, callbackUrl);
                string subject = "SortIt.Research approved";
                SendMailModel.SendMail(email, body, subject);

                return(Json("Research approved"));
            }
            catch (Exception ex)
            {
                return(Json("Fail!", JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
ファイル: StudentController.cs プロジェクト: h2002d/SortIt
        public void SendMail(Progress work)
        {
            var    Teacher = UserProfile.GetTeacherByStudentLessonId(work.StudentId, work.LessonId);
            string link    = string.Format("<div class='row' style='border:1px solid #808080' align='center'><p style='color:red'>New homework uploaded</p>" +
                                           "<a href='http://{0}/Files/homeworks/{1}'>{1}</a>" +
                                           "<input type='button' value='Approve' onclick='window.location.href='http://{0}/Teacher/Works''></div>", Request.Url.Authority, work.Attachement);

            SendMailModel.SendMail(Teacher.Email, link, "SortIt.Work published");
        }
コード例 #3
0
ファイル: StudentController.cs プロジェクト: h2002d/SortIt
        public void MailSender(int categoryId, int subject)
        {
            var users       = UserProfile.GetUserByInterest(categoryId);
            var currentUser = new UserProfile(User.Identity.GetUserId());
            var callbackUrl = Url.Action("SendRequestTeacher", "Manage", new { tId = User.Identity.GetUserId(), subId = subject }, protocol: Request.Url.Scheme);

            foreach (var user in users)
            {
                SendMailModel.SendMail(user.Email, string.Format("Dear {0} {1}, <br> We have new student matching your account. Student name {2} {3}", user.Name, user.SurName, currentUser.Name, currentUser.SurName), string.Format("SortIt.Interest matching for {0} {1}", currentUser.Name, currentUser.SurName));
            }
        }
コード例 #4
0
ファイル: AccountController.cs プロジェクト: h2002d/SortIt
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email,
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    var currentUser = UserManager.FindByName(user.UserName);

                    var roleresult = UserManager.AddToRole(currentUser.Id, "Student");
                    //await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                    var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
                    StringBuilder body = new StringBuilder();
                    body.Append("<img src='http://www.sortitresearch.com/images/logo.jpg' ><br>")
                    .Append("<p>Dear " + model.Name + " " + model.LastName + "</p>")
                    .Append("<p>Welcome to SortIT.You recieved this email because you have registered a new account on SORTIT</p>")
                    .Append("<p>Please confirm your email by clicking on the following link: <a href=\"" + callbackUrl + "\">Confirm link</a>");
                    SendMailModel.SendMail(user.Email, body.ToString(), "SortIt. Confirm email");



                    HttpCookie myCookie = new HttpCookie("Info");
                    myCookie["Name"]    = model.Name;
                    myCookie["Surname"] = model.LastName;
                    myCookie.Expires    = DateTime.Now.AddDays(1d);
                    Response.Cookies.Add(myCookie);

                    return(RedirectToAction("ConfirmAccount", "Account", new { email = model.Email }));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View());
        }
コード例 #5
0
        public ActionResult SendMail(SendMailModel model, string id)
        {
            NewsModel entityModel = new NewsModel(id);
            string    captcha     = AccountUtil.GetCaptcha();

            if (!captcha.Equals(model.SendMailConfirmationCode, StringComparison.OrdinalIgnoreCase))
            {
                ModelState.AddModelError(string.Empty, "驗證碼錯誤");
            }
            else
            {
                model.SendMailTitle = string.Format("收到一封由【{0}】從產業永續發展整合資訊網的轉寄信:{1}。"
                                                    , model.SendMailName, entityModel.Name);
                model.SendMailContent += entityModel.Content;
                model.SendMail();
                EntityCounter(id, "Emailer");
                ViewData["SendMailOk"] = true;
            }
            return(View("Email", entityModel));
        }
コード例 #6
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"));
        }
コード例 #7
0
 public ActionResult ProfileInfo(UserProfile user)
 {
     if (ModelState.IsValid)
     {
         user.Save();
         if (user.isTeacher)
         {
             var    callbackUrl = Url.Action("ConfirmTeacher", "Manage", new { userId = user.Id }, protocol: Request.Url.Scheme);
             string email       = System.Web.Configuration.WebConfigurationManager.AppSettings["AdminEmail"];
             SendMailModel.SendMail(email, "User " + user.Name + " " + user.SurName + " wants to register as facilitator click <a href='" + callbackUrl + "'>here</a>" +
                                    " to confirm <br/>Dissertation link <a href='" + user.Dissertation + "'>" + user.Dissertation + "</a>", "SortIt. Facilitator request!");
         }
         if (User.IsInRole("Student"))
         {
             return(RedirectToAction("MySubjects", "Student"));
         }
         else
         {
             return(RedirectToAction("Index", "Home"));
         }
     }
     return(View());
 }