public ActionResult Index(string returnUrl)
        {
            LoggedUserInfo upsd = LoggedUserInfo.GetLoggedUserInfo();

            if (upsd != null)
            {
                return(Redirect("/Admin/Posts"));
            }
            ViewBag.ReturnUrl = returnUrl;
            return(View());
        }
 public ActionResult Edit(PostCategory postCategory)
 {
     if (ModelState.IsValid)
     {
         postCategory.UpdatedBy       = LoggedUserInfo.GetLoggedUserInfo().ID;
         db.Entry(postCategory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(postCategory));
 }
        public ActionResult Create(PostCategory postCategory)
        {
            if (ModelState.IsValid)
            {
                postCategory.CreatedBy = LoggedUserInfo.GetLoggedUserInfo().ID;
                db.PostCategory.Add(postCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(postCategory));
        }
        public ActionResult Index(ResetPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                PostDbContext db             = new PostDbContext();
                string        username       = LoggedUserInfo.GetLoggedUserInfo().Username;
                string        pp             = LoggedUserInfo.GetLoggedUserInfo().PasswordHash;
                string        passwoord_hash = Crypto.SHA256(model.PresentPassword);

                int res = db.Users.Where(x => x.Username == username && x.Password == passwoord_hash).Count();
                if (res == 1)
                {
                    //update password
                    try
                    {
                        Users u = db.Users.Where(x => x.Username == username && x.Password == passwoord_hash).SingleOrDefault();
                        u.Password = Crypto.SHA256(model.ConfirmPassword);
                        db.SaveChanges();

                        TempData["message"]   = "Successfully Changed Password. Login Again with new Password";
                        TempData["alertType"] = "success";

                        Session.Abandon();
                    }
                    catch (Exception)
                    {
                        TempData["message"]   = "Failed To Change Password";
                        TempData["alertType"] = "danger";
                    }
                }
                else
                {
                    TempData["message"]   = "Incorrect Old password";
                    TempData["alertType"] = "info";
                }
            }
            return(View(model));
        }