public ActionResult Signup(FacultyTable model)
 {
     //FacultyTable.Password = Crypto.Hash(FacultyTable.Password);
     using (var context = new MailProEntities())
     {
         //FacultyTable.Password = Crypto.Hash(FacultyTable.Password);
         FacultyTable Fac = new FacultyTable();
         //Fac.Password = Crypto.Hash(Fac.Password);
         var IsExist = IsEmailExist(model.FacultyEmail);
         if (IsExist)
         {
             ModelState.AddModelError("Email Exist", "Email already exist");
             return(View());
         }
         Fac.ActivationCode   = Guid.NewGuid();
         model.ActivationCode = Fac.ActivationCode;
         model.Password       = Crypto.Hash(model.Password);
         context.FacultyTable.Add(model);
         context.SaveChanges();
         Session["FacultyEmail"] = model.FacultyEmail;
         EmailVerification(model.FacultyID, model.FacultyEmail, Fac.ActivationCode.ToString());
         //ViewBag.Message = "A veification link has been sent to your email , Please verify to continue access";
     }
     //FacultyTable.Password = Crypto.Hash(FacultyTable.Password);
     return(RedirectToAction("VMSent"));
     //return View(model);
 }
        public ActionResult Login(Models.Membership model, FacultyTable faculty)
        {
            using (var context = new MailProEntities())
            {
                FacultyTable Fac      = new FacultyTable();
                FacultyTable faculty1 = new FacultyTable();
                faculty1 = context.FacultyTable.SingleOrDefault(m => m.FacultyEmail == model.FacultyEmail);
                var abc = faculty1.IsEmailVerified;
                Fac = context.FacultyTable.SingleOrDefault(n => n.FacultyEmail == model.FacultyEmail);
                int  fid     = Fac.FacultyID;
                var  y       = Crypto.Hash(model.Password);
                bool IsValid = context.FacultyTable.Any(x => x.FacultyEmail == model.FacultyEmail && x.Password == y && abc != null);
                if (IsValid)
                {
                    FormsAuthentication.SetAuthCookie(model.FacultyEmail, false);

                    Session["FacultyID"] = fid;

                    return(RedirectToAction("ShowSentEmail", "Email"));
                }
                else
                {
                    ViewBag.Msg = "Invalid Email or Password";
                }
                context.SaveChanges();
                ModelState.AddModelError("", "Invalid Email or Password");
                return(View());
            }
        }
        public ActionResult VerifyAccount(string id, Models.Membership model)
        {
            bool status = false;

            using (var context = new MailProEntities())
            {
                FacultyTable Fac = new FacultyTable();
                //Mp.Configuration.ValidateOnSaveEnabled = false;
                var v = context.FacultyTable.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault();
                if (v != null)
                {
                    Fac.IsEmailVerified = true;
                    v.IsEmailVerified   = Convert.ToBoolean(Fac.IsEmailVerified);
                    context.SaveChanges();
                    status = true;
                }
                else
                {
                    ViewBag.Message = "invalid request";
                }
                Session["IsEmailVerified"] = model.IsEmailVerified;
            }
            ViewBag.Status = status;
            return(View());
        }
示例#4
0
 public ActionResult Signup(FacultyTable model)
 {
     //FacultyTable.Password = Crypto.Hash(FacultyTable.Password);
     using (var context = new MailProEntities())
     {
         //FacultyTable.Password = Crypto.Hash(FacultyTable.Password);
         //FacultyTable Fac = new FacultyTable();
         //Fac.Password = Crypto.Hash(Fac.Password);
         model.Password = Crypto.Hash(model.Password);
         context.FacultyTable.Add(model);
         context.SaveChanges();
     }
     //FacultyTable.Password = Crypto.Hash(FacultyTable.Password);
     return(RedirectToAction("Login"));
 }
示例#5
0
        public async Task sendprocess(StudentTable st, FacultyTable ft, Mails model)
        {
            try
            {
                var FromEmail         = new MailAddress(ft.FacultyEmail, ft.FacultyName);
                var ToEmail           = new MailAddress(st.StudentEmail);
                var FromEmailPassword = model.GmailPassword;

                string URL     = Session["TemplateUrl"].ToString();
                string Subject = model.Subject;
                string content = model.Contents;
                if (content == null)
                {
                    model.Contents = "The Mail is sent by using template. Hence no preview is available.";
                }
                string Body = "Hello " + st.StudentName + ",<br/><br/>" + model.Contents;
                Body = PopulateBody(Body, URL);

                SmtpClient smtp = new SmtpClient()
                {
                    Host                  = "smtp.gmail.com",
                    Port                  = 587,
                    EnableSsl             = true,
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Credentials           = new NetworkCredential(FromEmail.Address, FromEmailPassword)
                };


                /*model.GmailPassword = Crypto.Hash(model.GmailPassword);
                 * context.Mails.Add(model);
                 * context.SaveChanges();*/
                using (var message = new MailMessage(FromEmail, ToEmail)
                {
                    Subject = Subject,
                    Body = Body,
                    IsBodyHtml = true
                })

                    await smtp.SendMailAsync(message);
                ViewBag.Message = "Your Mail Has been sent successfully";
            }
            catch (SmtpFailedRecipientsException ex)
            {
                ModelState.AddModelError("", "There is some error sending the mails, please recheck your internet connection and password");
            }
        }
示例#6
0
        private void FacultyTable()
        {
            FacultyTable faculty = new FacultyTable();
            string       road    = @"Faculties.txt";

            using (UniversityContext context = new UniversityContext())
            {
                StreamReader sr = new StreamReader(road, Encoding.GetEncoding(1251));
                while (!sr.EndOfStream)
                {
                    faculty.FacultyName = sr.ReadLine();
                    context.Faculties.Add(faculty);
                    context.SaveChanges();
                }
                sr.Close();
            }
        }
示例#7
0
        public async Task EmailSent(Mails model)
        {
            List <int>   fetch   = (List <int>)Session["MailTransfer"];
            int          Fac     = (int)Session["FacultyID"];
            FacultyTable ft      = new FacultyTable();
            var          context = new MailProEntities();

            ft = context.FacultyTable.Find(Fac);
            try
            {
                StudentTable st = new StudentTable();
                foreach (var item in fetch)
                {
                    st = context.StudentTable.SingleOrDefault(x => x.StudentNo == item);
                    await sendprocess(st, ft, model);
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "There was some error in sending mail , Recheck your password and internet connection");
            }
        }