From 580f83a2ab4767c9c07093d47f87707a4564becf Mon Sep 17 00:00:00 2001 From: Nobir Date: Mon, 18 Jul 2022 05:02:45 +0600 Subject: [PATCH] [Added] create user model (main perpose to validation) --- Models/UserCreateAdminModel.cs | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Models/UserCreateAdminModel.cs diff --git a/Models/UserCreateAdminModel.cs b/Models/UserCreateAdminModel.cs new file mode 100644 index 0000000..1ce81af --- /dev/null +++ b/Models/UserCreateAdminModel.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Web; +using ERPSystemTimologio.EF; + +namespace ERPSystemTimologio.Models +{ + public class UserCreateAdminModel : User + { + [Required] + [RegularExpression(@"^[10]+$", ErrorMessage = "The field must 0 or 1")] + public new int Verified { get; set; } + [Required] + [MinLength(3)] + public new string Name { get; set; } + + [Required] + [MinLength(3)] + [UniqueUsernameValidation] + public new string Username { get; set; } + + [Required] + [EmailAddress] + [UniqueEmailValidation] + public new string Email { get; set; } + + [Required] + [Range(0, 500000)] + public new double? Salary { get; set; } + + [Required] + [MinLength(8)] + [RegularExpression(@"^(?=.*[!@#$%^&*)(])(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+$", ErrorMessage = "Password must contain at least one special character, one uppercase letter, one lowercase letter and one digit.")] + public new string Password { get; set; } + + [Compare("Password")] + public string CPassword { get; set; } + + [Required] + [DataType(DataType.Date)] + [DisplayFormat(DataFormatString = "yyyy-MM-dd")] + public new DateTime? HireDate { get; set; } + + [Required] + [Range(1, 4)] + public new int Type { get; set; } + + [Range(0, int.MaxValue)] + public new int? RegionId { get; set; } + + [Range(0, int.MaxValue)] + public new int? BranchId { get; set; } + + public string LocalAddress { get; set; } + + public string PoliceStation { get; set; } + + public string City { get; set; } + + public string Country { get; set; } + + public string ZipCode { get; set; } + + public List PermissionIds { get; set; } + } +} \ No newline at end of file