public JsonResult changeUserRole(user_account user)
        {
            var selectedUser = db.user_account.Where(x => x.userAccountId == user.userAccountId).FirstOrDefault();
            var type         = user.userTypeID;

            selectedUser.userTypeID = type;
            db.SaveChanges();
            var teacher = db.user_teacher.Where(x => x.userAccountID == selectedUser.userAccountId).FirstOrDefault();

            db.user_teacher.Remove(teacher);
            db.SaveChanges();
            if (user.userTypeID != 1)
            {
                var userT = new user_student();
                userT.userAccountID = selectedUser.userAccountId;
                db.user_student.Add(userT);
                db.SaveChanges();
            }
            else
            {
                var admin = new user_admin();
                admin.adminAccountId    = selectedUser.userAccountId;
                admin.adminEmail        = selectedUser.userEmail;
                admin.adminName         = selectedUser.firstName;
                admin.adminSurname      = selectedUser.lastName;
                admin.adminRegisterDate = DateTime.Now;
                admin.adminPassword     = selectedUser.userPassword;
                admin.adminIsActive     = selectedUser.userIsActive;
                db.user_admin.Add(admin);
                db.user_account.Remove(selectedUser);
                db.SaveChanges();
            }
            db.SaveChanges();
            return(Json(JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public ActionResult Reject_user(string name)
        {
            var data = (from r in db.and_user_tbl
                        where r.pk_email_id == name
                        select r).FirstOrDefault();

            data.status = "Rejected";
            user_admin _ua = new user_admin();

            _ua.status = data.status;
            db.SaveChanges();
            return(RedirectToAction("user_all_admin"));
        }
Esempio n. 3
0
        public ActionResult Login(user_admin usr)
        {
            user_admin loginned = db.user_admin.FirstOrDefault(u => u.email == usr.email);

            if (loginned != null)
            {
                if (Crypto.VerifyHashedPassword(loginned.password, usr.password))
                {
                    Session["loginned"] = true;
                    Session["usrid"]    = loginned.id;
                    return(RedirectToAction("index", "dashboard"));
                }
            }
            Session["LoginInvalid"] = true;
            return(RedirectToAction("index"));
        }
Esempio n. 4
0
        public ActionResult user_delete(string name)
        {
            var data = (from r in db.and_user_tbl
                        where r.pk_email_id == name
                        select r).FirstOrDefault();

            data.status = "Deleted";
            user_admin _ua = new user_admin();

            _ua.status = data.status;
            if (data.photo != null || data.photo != "")
            {
                System.IO.File.Delete(Server.MapPath(data.photo));
            }

            db.and_user_tbl.Remove(data);
            db.SaveChanges();

            return(RedirectToAction("user_all_admin"));
        }
        public ActionResult ForgetPassword(user_admin user)
        {
            bool exist = isEmailExist(user.adminEmail);

            if (exist == false)
            {
                ViewBag.Warning = "E-mail adresi bulunamadı.";
            }
            else
            {
                string token     = Guid.NewGuid().ToString();
                var    verifyUrl = "Change/ResetPassword/" + token;
                var    link      = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, verifyUrl);
                var    selected  = db.user_admin.Where(x => x.adminEmail == user.adminEmail).FirstOrDefault();
                selected.adminResetCode = token;
                db.SaveChanges();
                var subject = "Parola Yenileme Talebi";
                var body    = "Merhaba " + selected.adminName + ", <br/> Hesabınız için parola yenileme talebinde bulundunuz. Aşağıdaki linke tıklayarak parolanızı yenileyebilirsiniz." + "<br/><br/><a href='" + link + "'>Buraya Tıklayınız</a> <br/><br/>" + "Teşekkürler";
                sendEmail(selected.adminEmail, body, subject);
                ViewBag.Success = "Parola yenileme linki e-adresinize gönderildi.";
            }
            return(View());
        }
Esempio n. 6
0
        //public ActionResult testi_delete(string name)
        //{
        //    var data = (from r in db.and_testimonials_tbl
        //                where r.fk_email_id == name
        //                select r).FirstOrDefault();
        //    data.status = "Deleted";
        //    testimonial_admin _ta = new testimonial_admin();
        //    _ta.status = data.status;
        //    db.and_testimonials_tbl.Remove(data);
        //    db.SaveChanges();

        //    return RedirectToAction("testi_all_admin");
        //}
        public ActionResult DeleteAll_testi(FormCollection frm)
        {
            var chkvalue = frm.GetValues("assignChkBx");

            foreach (var id in chkvalue)
            {
                user_admin n_m  = new user_admin();
                string     id1  = id;
                var        data = (from c in db.and_testimonials_tbl where c.fk_email_id == id1 select c).First();

                if (data.photo != null || data.photo != "")
                {
                    if (data.photo != "~/Blog_image/no_image.gif")
                    {
                        System.IO.File.Delete(Server.MapPath(data.photo));
                    }
                }

                db.and_testimonials_tbl.Remove(data);
                db.SaveChanges();
            }
            return(RedirectToAction("testi_all_admin", "Admin_user"));
        }
Esempio n. 7
0
 public ActionResult PersonalInfo(user_admin ad)
 {
     if (ModelState.IsValid)
     {
         var admin = db.user_admin.Where(x => x.adminAccountId == ad.adminAccountId).FirstOrDefault();
         if (admin != null)
         {
             admin.adminName    = ad.adminName;
             admin.adminSurname = ad.adminSurname;
             admin.adminEmail   = ad.adminEmail;
             db.SaveChanges();
             ViewBag.Success = "Değişikliler başarı ile yapıldı.";
         }
         else
         {
             ViewBag.Warning = "Kullanıcı bulunamadı. Tekrar deneyiniz.";
         }
     }
     else
     {
         ViewBag.Warning = "Değişiklikler yapılamadı. Tekrar deneyiniz.";
     }
     return(View(ad));
 }