Guest User

Untitled

a guest
Jan 30th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.Linq;
  5. using System.Web;
  6.  
  7. namespace finalProject.Models
  8. {
  9. public class ForgetLoginModel
  10. {
  11. public int UserId { get; set; }
  12.  
  13. public string VerificationCode { get; set; }
  14.  
  15. [Required(ErrorMessage = "Please Enter New Password")]
  16. [StringLength(10, MinimumLength = 5, ErrorMessage = "Password should be min 5 or Max 10 Charators")]
  17. public string NewPass { get; set; }
  18.  
  19. [Required(ErrorMessage = "Please Enter Confirm Password")]
  20. [Compare("NewPass", ErrorMessage = "Password and confirm password
  21. doesnot matched")]
  22. public string ConfPassword { get; set; }
  23. }
  24.  
  25. [HttpGet]
  26. public ActionResult ForGettingPass()
  27. {
  28. return View();
  29. }
  30. [HttpPost]
  31. public ActionResult ForGettingPass(ForgetLoginModel obj)
  32. {
  33. DemoContext _context = new DemoContext();
  34. User objUser = new User();
  35. try
  36. {
  37. objUser = _context.Users.Where(x => x.VerificationCode.Equals(obj.VerificationCode)).SingleOrDefault();
  38.  
  39. objUser.Password = obj.NewPass;
  40.  
  41. TempData.Add("PasUpdateAlert", new AlertModel("your Password have been Updated Successfully..!", AlertType.Success));
  42.  
  43. }
  44. catch (Exception e)
  45. {
  46. TempData.Add("PasUpdateAlert", new AlertModel("Please Confirm Your Verification first", AlertType.Error));
  47. }
  48. _context.Entry(objUser.Password).State = System.Data.Entity.EntityState.Modified;
  49. _context.SaveChanges();
  50. return View();
  51. }
Add Comment
Please, Sign In to add comment