Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
- using System.Linq;
- using System.Web;
- namespace finalProject.Models
- {
- public class ForgetLoginModel
- {
- public int UserId { get; set; }
- public string VerificationCode { get; set; }
- [Required(ErrorMessage = "Please Enter New Password")]
- [StringLength(10, MinimumLength = 5, ErrorMessage = "Password should be min 5 or Max 10 Charators")]
- public string NewPass { get; set; }
- [Required(ErrorMessage = "Please Enter Confirm Password")]
- [Compare("NewPass", ErrorMessage = "Password and confirm password
- doesnot matched")]
- public string ConfPassword { get; set; }
- }
- [HttpGet]
- public ActionResult ForGettingPass()
- {
- return View();
- }
- [HttpPost]
- public ActionResult ForGettingPass(ForgetLoginModel obj)
- {
- DemoContext _context = new DemoContext();
- User objUser = new User();
- try
- {
- objUser = _context.Users.Where(x => x.VerificationCode.Equals(obj.VerificationCode)).SingleOrDefault();
- objUser.Password = obj.NewPass;
- TempData.Add("PasUpdateAlert", new AlertModel("your Password have been Updated Successfully..!", AlertType.Success));
- }
- catch (Exception e)
- {
- TempData.Add("PasUpdateAlert", new AlertModel("Please Confirm Your Verification first", AlertType.Error));
- }
- _context.Entry(objUser.Password).State = System.Data.Entity.EntityState.Modified;
- _context.SaveChanges();
- return View();
- }
Add Comment
Please, Sign In to add comment