AccountModels.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.ComponentModel.DataAnnotations.Schema;
  5. using System.Data.Entity;
  6. using System.Globalization;
  7. using System.Web.Mvc;
  8. using System.Web.Security;
  9. namespace EMISOnline.Web.Models
  10. {
  11. public class UsersContext : DbContext
  12. {
  13. public UsersContext()
  14. : base("DefaultConnection")
  15. {
  16. }
  17. public DbSet<UserProfile> UserProfiles { get; set; }
  18. }
  19. [Table("UserProfile")]
  20. public class UserProfile
  21. {
  22. [Key]
  23. [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
  24. public int UserId { get; set; }
  25. public string UserName { get; set; }
  26. }
  27. public class RegisterExternalLoginModel
  28. {
  29. [Required]
  30. [Display(Name = "用户名")]
  31. public string UserName { get; set; }
  32. public string ExternalLoginData { get; set; }
  33. }
  34. public class LocalPasswordModel
  35. {
  36. [Required]
  37. [DataType(DataType.Password)]
  38. [Display(Name = "当前密码")]
  39. public string OldPassword { get; set; }
  40. [Required]
  41. [StringLength(100, ErrorMessage = "{0} 必须至少包含 {2} 个字符。", MinimumLength = 6)]
  42. [DataType(DataType.Password)]
  43. [Display(Name = "新密码")]
  44. public string NewPassword { get; set; }
  45. [DataType(DataType.Password)]
  46. [Display(Name = "确认新密码")]
  47. [Compare("NewPassword", ErrorMessage = "新密码和确认密码不匹配。")]
  48. public string ConfirmPassword { get; set; }
  49. }
  50. public class LoginModel
  51. {
  52. [Required]
  53. [Display(Name = "用户名")]
  54. public string UserName { get; set; }
  55. [Required]
  56. [DataType(DataType.Password)]
  57. [Display(Name = "密码")]
  58. public string Password { get; set; }
  59. [Display(Name = "记住我?")]
  60. public bool RememberMe { get; set; }
  61. }
  62. public class RegisterModel
  63. {
  64. [Required]
  65. [Display(Name = "用户名")]
  66. public string UserName { get; set; }
  67. [Required]
  68. [StringLength(100, ErrorMessage = "{0} 必须至少包含 {2} 个字符。", MinimumLength = 6)]
  69. [DataType(DataType.Password)]
  70. [Display(Name = "密码")]
  71. public string Password { get; set; }
  72. [DataType(DataType.Password)]
  73. [Display(Name = "确认密码")]
  74. [Compare("Password", ErrorMessage = "密码和确认密码不匹配。")]
  75. public string ConfirmPassword { get; set; }
  76. }
  77. public class ExternalLogin
  78. {
  79. public string Provider { get; set; }
  80. public string ProviderDisplayName { get; set; }
  81. public string ProviderUserId { get; set; }
  82. }
  83. }