Esempio n. 1
0
        public void RecieveMail(EmailViewmodel model)
        {
            MakeApplicationViewModel mo = new MakeApplicationViewModel();

            try
            {
                var m = new MailMessage
                {
                    Subject    = "New Applicant",
                    Body       = model.Message,
                    IsBodyHtml = true,
                    From       = new MailAddress(mo.Phone, "Applicant")
                };
                m.To.Add(model.To);

                var smtp = new SmtpClient
                {
                    Host        = "pod51014.outlook.com",
                    Credentials = new NetworkCredential("*****@*****.**", "Dut921208"),
                    EnableSsl   = true,
                    Port        = 587
                };

                smtp.Send(m);
            }
            catch
            {
                //send sms instead
            }
        }
Esempio n. 2
0
        public void SendMail(EmailViewmodel model)
        {
            try
            {
                var m = new MailMessage
                {
                    Subject    = "Login Credentials",
                    Body       = model.Message,
                    IsBodyHtml = true,
                    From       = new MailAddress("*****@*****.**", "JG-Administrator")
                };
                m.To.Add(model.To);

                var smtp = new SmtpClient
                {
                    Host        = "pod51014.outlook.com",
                    Credentials = new NetworkCredential("*****@*****.**", "Dut921208"),
                    EnableSsl   = true,
                    Port        = 587
                };

                smtp.Send(m);
            }
            catch
            {
                //send sms instead
            }
        }
Esempio n. 3
0
        public void AddApplicant(ApplicationViewModel app)
        {
            var newdaplicant = new ApplicationTable
            {
                Applicant_IDNumber      = app.Applicant_IDNumber,
                Applicant_Name          = app.Applicant_Name,
                Applicant_Surname       = app.Applicant_Surname,
                Applicant_Date_Of_Birth = app.Applicant_Date_Of_Birth,
                Applicant_Gender        = app.Applicant_Gender,
                Application_Grade       = "Grade_8",
                Applicant_Religion      = app.Applicant_Religion,
                Applicant_Adress        = app.Applicant_Adress,
                Maths_Mark            = app.Maths_Mark,
                English_Mark          = app.English_Mark,
                ZuluHomeLanguage_Mark = app.ZuluHomeLanguage_Mark,
                status         = "Awaiting",
                Title          = app.Title,
                Parent_Name    = app.Parent_Name,
                Parent_Surname = app.Parent_Surname,
                Parent_Number  = app.Parent_Number,
                Parent_Adress  = app.Parent_Adress,
                Parent_Email   = app.Parent_Email,
            };

            uow.Repository <ApplicationTable>().Insert(newdaplicant);
            uow.Save();

            EmailViewmodel emv   = new EmailViewmodel();
            EmailBL        email = new EmailBL();



            emv.Message = "Dear Admin  :" + app.Parent_Email + "\n" +
                          "New Applicant has Submited An Application" + "\n" +
                          "Please Check Application ";
            emv.Subject = "New Applicant";
            emv.To      = "*****@*****.**"; /*"*****@*****.**"*/;
            email.SendMail(emv);
        }
Esempio n. 4
0
        public void Register(RegistrationViewModel model, HttpPostedFileBase image)
        {
            var password = "******";
            var user     = new ApplicationUser()
            {
                UserName = model.Parent_Email,
                Email    = model.Parent_Email
            };
            string gen;
            string seven   = model.Student_IDNumber.Substring(6, 1);
            int    seventh = Convert.ToInt16(seven);

            if (seventh == 0 || seventh <= 4)
            {
                gen = "Female";
            }
            else
            {
                gen = "Male";
            }

            if (image != null)
            {
                model.AddPhoto = new byte[image.ContentLength];
                image.InputStream.Read(model.AddPhoto, 0, image.ContentLength);
            }

            StudentTable stud = new StudentTable
            {
                Student_Number        = model.Student_Number,
                Student_Name          = model.Student_Name,
                Student_Surname       = model.Student_Surname,
                Student_Gender        = gen,
                Student_Religion      = model.Student_Religion,
                Student_Adress        = model.Student_Adress,
                Student_Date_Of_Birth = model.Student_Date_Of_Birth,
                Student_IDNumber      = model.Student_IDNumber,
                Enrolment_Date        = model.Enrolment_Date,
                Role = model.Role,
                //AddPhoto=model.AddPhoto,
                Stream_Code     = model.Stream_Code,
                ClassGroupe_id  = model.ClassGroupe_id,
                Grade_id        = model.Grade_id,
                status          = model.status,
                Parent_Identity = model.Parent_Identity,
            };

            uow.Repository <StudentTable>().Insert(stud);
            var result = userManager.Create(user, password);

            if (result.Succeeded)
            {
                if (!roleManager.RoleExists(model.Role))
                {
                    roleManager.Create(new IdentityRole()
                    {
                        Name = model.Role
                    });
                }
                userManager.AddToRole(user.Id, model.Role);
            }

            Parent ppar = new Parent
            {
                Parent_Identity = model.Parent_Identity,
                Title           = model.Title,
                Parent_Name     = model.Parent_Name,
                Parent_Surname  = model.Parent_Surname,
                Parent_Number   = model.Parent_Number,
                Parent_Adress   = model.Parent_Adress,
                Parent_Email    = model.Parent_Email,
            };

            uow.Repository <Parent>().Insert(ppar);
            uow.Save();

            EmailViewmodel emv   = new EmailViewmodel();
            EmailBL        email = new EmailBL();



            emv.Message = "Dear Parent  :" + model.Parent_Email + "\n" +
                          "Your Child has Registered to JG Zuma High School" + "\n" +
                          "Please make sure you attend meeting  " +
                          "Out Standing School Fee:R 150.00" + "\n" +
                          "LogIn Creaditials are: password:"******"UserName :"******"JG-Zuma Registration Feedback";
            emv.To      = model.Parent_Email;
            email.SendMail(emv);
        }
Esempio n. 5
0
        public void AddNewStaffprofile(StaffViewModel model, HttpPostedFileBase image)
        {
            var    password = "******";
            string gen;
            string seven   = model.IdentityNumber.Substring(6, 1);
            int    seventh = Convert.ToInt16(seven);

            if (seventh == 0 || seventh <= 4)
            {
                gen = "Female";
            }
            else
            {
                gen = "Male";
            }
            if (image != null)
            {
                model.AddPhoto = new byte[image.ContentLength];
                image.InputStream.Read(model.AddPhoto, 0, image.ContentLength);
            }
            var user = new ApplicationUser
            {
                UserName = model.Email,
                Email    = model.Email,
            };


            var st = new Staff
            {
                Stuff_Number      = model.Stuff_Number,
                Registration_Date = model.Registration_Date,
                FirstName         = model.FirstName,
                LastName          = model.LastName,
                ContactNumber     = model.ContactNumber,
                Email             = model.Email,
                Password          = password,
                IdentityNumber    = model.IdentityNumber,
                AddPhoto          = model.AddPhoto,
                Role   = model.Role,
                Gender = gen
            };

            uow.Repository <Staff>().Insert(st);
            uow.Save();


            EmailViewmodel emv   = new EmailViewmodel();
            EmailBL        email = new EmailBL();



            emv.Message = "Dear Parent  :" + model.Email + "\n" +
                          "Your Child has Registered to JG Zuma High School" + "\n" +
                          "Please make sure you attend meeting  " +
                          "Out Standing School Fee:R 150.00" + "\n" +
                          "LogIn Creaditials are: password:"******"UserName :"******"JG-Zuma Registration Feedback";
            emv.To      = model.Email;
            email.SendMail(emv);



            var result = UserManager.Create(user, password);

            if (result.Succeeded)
            {
                if (!RoleManager.RoleExists(model.Role))
                {
                    RoleManager.Create(new IdentityRole()
                    {
                        Name = model.Role
                    });
                }
                UserManager.AddToRole(user.Id, model.Role);
            }
        }