コード例 #1
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            // action çalışmadan önce yapılacak işlemler

            var ent = new EgitimMerkeziEntities();
            if (HttpContext.Current.Session["eposta"] == null)
            {
                filterContext.HttpContext.Response.Redirect("~/Home/Register");
            }
            else
            {
                string Eposta = HttpContext.Current.Session["eposta"].ToString();
                var uye_rol = ent.Ogrenci.FirstOrDefault(x => x.Eposta == Eposta).Role;
                if (uye_rol != "Admin")
                {
                    filterContext.HttpContext.Response.Redirect("~/Home/Index");
                }
            }
            base.OnActionExecuting(filterContext);
        }
コード例 #2
0
 public static string OgrenciBilgiGetir(string eposta)
 {
     var ent = new EgitimMerkeziEntities();
     var ogrenci_bilgi =ent.Ogrenci.FirstOrDefault(x => x.Eposta == eposta);
     string adsoyad = ogrenci_bilgi.Ad + " " + ogrenci_bilgi.Soyad;
     return adsoyad;
 }
コード例 #3
0
 public static string RoleGetir(string eposta)
 {
     var ent = new EgitimMerkeziEntities();
     var uye_rol = ent.Ogrenci.FirstOrDefault(x => x.Eposta == eposta).Role;
     return uye_rol;
 }
コード例 #4
0
 public ActionResult Aktivasyon(string eposta, string aktivasyonkodu)
 {
     var ent = new EgitimMerkeziEntities();
     var uye = ent.Ogrenci.Where(x => x.Eposta == eposta && x.Aktivasyon == aktivasyonkodu).FirstOrDefault();
     if (uye != null)
     {
         uye.Onay = true;
         ent.SaveChanges();
         return View();
     }
     return RedirectToAction("Index", "Home");
 }
コード例 #5
0
 public ActionResult UyeGiris(RegisterViewModel LoginModel)
 {
     if (ModelState.IsValid)
     {
         var ent = new EgitimMerkeziEntities();
         string sifre = FormsAuthentication.HashPasswordForStoringInConfigFile(LoginModel.Password, "md5");
         var uye = ent.Ogrenci.Where(x => x.Eposta == LoginModel.Email && x.Sifre == sifre && x.Onay == true).FirstOrDefault();
         if (uye != null)
         {
             Session["eposta"] = LoginModel.Email;
             Session["role"] = uye.Role;
             return RedirectToAction("Index", "Home");
         }
         else
         {
             TempData["Mesaj"] = "Kullanıcı Adı veya şifre yanlış, eposta aktivasyon maili onaylanmamıştır";
         }
     }
     return View("Login");
 }
コード例 #6
0
 public ActionResult UyeEkle(RegisterViewModel RegisterModel)
 {
     var ent = new EgitimMerkeziEntities();
     Ogrenci _kursogrenci = new Ogrenci();
     string aktivasyonkodu = Guid.NewGuid().ToString("N").Substring(0, 20).ToUpper();
     _kursogrenci.Ad = RegisterModel.Ad;
     _kursogrenci.Soyad = RegisterModel.Soyad;
     _kursogrenci.Telefon = RegisterModel.Telefon;
     _kursogrenci.Eposta = RegisterModel.Email;
     _kursogrenci.Sifre = FormsAuthentication.HashPasswordForStoringInConfigFile(RegisterModel.Password, "md5");
     _kursogrenci.Aktivasyon = aktivasyonkodu;
     _kursogrenci.Onay = false;
     _kursogrenci.Role = "Kullanici";
     _kursogrenci.KayitTarihi = DateTime.Now;
     ent.Ogrenci.Add(_kursogrenci);
     ent.SaveChanges();
     string mailIcerik = "EĞİTİM MERKEZİ AİLESİNE HOSGELDİNIZ<br>www.egitimmerkezi.com a kayıt olduğunuz için teşekkür ederiz. <br> Üyeliğinizi onaylamak için doğrulamak için aşağıdaki linke tıklayınız.<br> ";
     //mailIcerik += "<a href=\"http://egitimmerkezi.sakarya.edu.tr/Home/Aktivasyon?Eposta=" + RegisterModel.Email + "&AktivasyonKodu=" + aktivasyonkodu + "\" style=\"text-decoration:underline; color:#3ba5d8;\">Üyeliğimi Aktifleştir</a>";
     mailIcerik += "<a href=\"http://egitimmerkezi.sakarya.edu.tr/Home/Aktivasyon?Eposta=" + RegisterModel.Email + "&AktivasyonKodu=" + aktivasyonkodu + "\" style=\"text-decoration:underline; color:#3ba5d8;\">Üyeliğimi Aktifleştir</a>";
     MailGonder(RegisterModel.Email, "Eğitim Merkezi ~ Üyelik Aktivasyon", mailIcerik);
     return View("RegisterMessage");
 }