コード例 #1
0
        public void SendRemember()
        {
            string emails = "";

            foreach (var student in this.Course.Students)
            {
                emails += student.Email + " ";
            }
            string emailBody = "Hi , there is " + this.Course.Teacher.Name + " fom course " + this.Course.Name + ". <br /> I want to remember you about home work '" + this.Title + "'";

            Mailer.Mailer mail = new Mailer.Mailer();
            mail.SetGeter(emails);
            mail.SetTitleAndBody("Home work remember", emailBody);
            mail.Send();
        }
コード例 #2
0
        public async Task <RegistrationStatus> RegisterStudent(CreateStudentView model)
        {
            RegistrationStatus status = model.Verify();

            try
            {
                if (status.Result)
                {
                    var user = new ApplicationUser()
                    {
                        UserName = model.UserName
                    };
                    user.Student = new Student(model);
                    user.Role    = ApplicationConstants.STUDENT;
                    string passowrd = Membership.GeneratePassword(10, 0);  // will be password
                    var    result   = await UserManager.CreateAsync(user, passowrd);

                    status = new RegistrationStatus(model, result.Succeeded, StudentRegResults.OK, result.Errors);
                    if (result.Succeeded)
                    {
                        var student = UserManager.FindByName(user.UserName);
                        UserManager.AddToRole(student.Id, ApplicationConstants.STUDENT);
                        Mailer.Mailer mail = new Mailer.Mailer();
                        mail.SetGeter(user.Student.Email);
                        string emailText = "You was ordet to the course ****** , by *******. <br /> ";
                        emailText += "User name: " + user.UserName + " <br /> ";
                        emailText += "Password: "******"Order to Course", emailText);
                        mail.Send();
                    }
                }
            }
            catch (Exception ex)
            {
                status = new RegistrationStatus(model, false, StudentRegResults.Exception, new List <string>()
                {
                    ex.Message
                });
            }

            return(status);
        }