You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.0 KiB

4 years ago
  1. using Business.Account;
  2. using Business.Configuration;
  3. using Common.Helper;
  4. using Common.Model;
  5. using Common.Model.Account;
  6. using Newtonsoft.Json;
  7. using System;
  8. using System.Web.UI;
  9. namespace JMEAgentSystem.WebPages.Account
  10. {
  11. public partial class ChangePassword : Page
  12. {
  13. private readonly IAccountServices _accountServices = AutoFacContainer.Resolve<IAccountServices>();
  14. protected void Page_Load(object sender, EventArgs e)
  15. {
  16. var methodName = GetStatic.ReadFormData("MethodName", "");
  17. if (methodName == "ChangePassword")
  18. Change_Password();
  19. }
  20. private void Change_Password()
  21. {
  22. PasswordChangeModel model = new PasswordChangeModel()
  23. {
  24. ReferralCode = GetStatic.GetUser(),
  25. Password = GetStatic.ReadFormData("Password", ""),
  26. NewPassword = GetStatic.ReadFormData("NewPassword", ""),
  27. ConformNewPassword = GetStatic.ReadFormData("ConformNewPassword", ""),
  28. IpAddress = GetStatic.GetIpAddress(Request),
  29. UserDetails = GetStatic.GetUserInfo(Request),
  30. };
  31. DbResponse result;
  32. if (model.Password != model.NewPassword)
  33. result = new DbResponse()
  34. {
  35. ResponseCode = "1",
  36. Msg = "Old Password And New Password Can't Be Same!"
  37. };
  38. if (model.NewPassword != model.ConformNewPassword)
  39. result = new DbResponse()
  40. {
  41. ResponseCode = "1",
  42. Msg = "New Password And Conform New Password Must Be Match!"
  43. };
  44. else
  45. result = _accountServices.ChangePassword(model);
  46. Response.ContentType = "text/plain";
  47. string json = JsonConvert.SerializeObject(result);
  48. Response.Write(json);
  49. Response.End();
  50. }
  51. }
  52. }