示例#1
0
        public ActionResult ChangePassword(ChangePassword changePassword)
        {
            if (ModelState.IsValid)
            {
                if (Crypto.VerifyHashedPassword(_db.AdminSettings.First().Password, changePassword.OldPassword))
                {
                    _db.AdminSettings.First().Password = Crypto.HashPassword(changePassword.NewPassword);
                    _db.SaveChanges();

                    Session.Clear();
                    return(RedirectToAction("Login"));
                }

                ModelState.AddModelError("OldPassword", "Old password is wrong.");
            }

            return(View(changePassword));
        }
        [HttpPost]    // Seyifede Slider tipinden gelenler olacaq Image-siz, Image ayrica gonderilrcek
        public ActionResult Create([Bind(Exclude = "Image")] Slider slider, HttpPostedFileBase Image)
        {
            if (ModelState.IsValid)
            {
                if (Extensions.CheckImageType(Image) && Extensions.CheckImageSize(Image, 10))
                {
                    // verilen shekii metod vasitesi ile adini deyish ve bu unvanda saxla
                    slider.Image = Extensions.SaveImage(Server.MapPath("~/Public/img/intro"), Image);

                    _db.Sliders.Add(slider);
                    _db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("Image", "Seklin tipi duzgun deyil ve ya olcusu 10mb-dan artiqdir.");
                }
            }

            return(View());
        }