Hadeel e

Hadeel e

  • NA
  • 50
  • 6.6k

Generating a user profile in mvc5

Apr 21 2020 5:31 PM

In my app I have a driver users and a customer users(rider), I am trying to create a profile for each one of them. and in my driver model I have the following:


  1. public class DriversModel  
  2.     {  
  3.             [Display(Name ="Id")]  
  4.             public int driverId { getset; }  
  5.   
  6.             [Display(Name = "First Name")]  
  7.             [Required(ErrorMessage = "Pleas Enter Your First Name")]  
  8.             public string firstName { getset; }  
  9.   
  10.             [Display(Name = "Last Name")]  
  11.             [Required(ErrorMessage = "Pleas Enter Your Last Name")]  
  12.             public string lastName { getset; }  
  13.   
  14.             [Display(Name = "Email Address")]  
  15.             [DataType(DataType.EmailAddress)]  
  16.             [Required(ErrorMessage = "Pleas Enter Your Email Address")]  
  17.             [RegularExpression(".+\\@.+\\..+", ErrorMessage = "Please Enater a Valid Email Address")]  
  18.             public string email { getset; }  
  19.   
  20.             [Display(Name = "Mobile Number")]  
  21.             [Required(ErrorMessage = "Pleas Enter Your Mobile Number")]  
  22.             public string phoneNumber { getset; }  
  23.   
  24.             [Display(Name = "Address")]  
  25.             [Required(ErrorMessage = "Pleas Enter Your Address")]  
  26.             public string Address { getset; }  
  27.   
  28.             [Display(Name = "City")]  
  29.             [Required(ErrorMessage = "Pleas Enter Your City")]  
  30.             public string city { getset; }  
  31.   
  32.             [Display(Name = "State")]  
  33.             [Required(ErrorMessage = "Pleas Enter Your state")]  
  34.             public string state { getset; }  
  35.   
  36.             [Display(Name = "Car")]  
  37.             [Required(ErrorMessage = "Please Identify Your Car")]  
  38.             public string car { getset; }  
  39.   
  40.             [Display(Name = "Driver's License")]   
  41.             [Required(ErrorMessage = "Please Enter Your Driver's Licende Number")]  
  42.             public string driverslicense { getset; }  
  43.   
  44.   
  45.             [Display(Name ="Profile Image")]  
  46.             [Required]  
  47.             public byte[] profileImg { getset; }  
  48.   
  49.             public string profileImgType { getset; }  
  50.   
  51.             [Display(Name = "License Image")]  
  52.             [Required]  
  53.             public byte[] licenseImg { getset; }  
  54.   
  55.             public string licenseImgType { getset; }  
  56.   
  57.            [Display(Name ="Password")]  
  58.            [DataType(DataType.Password)]  
  59.            [Required(ErrorMessage ="Please Enter a password")]  
  60.            public string PasswordHash { getset; }  
  61.   
  62.     } 

and in the customer model:

  1. public class RidersModel  
  2.     {  
  3.   
  4.        [Display(Name ="Id")]  
  5.        public int usersId { getset; }  
  6.   
  7.   
  8.         [Display(Name = "First Name")]  
  9.         [Required(ErrorMessage = "Pleas Enter Your First Name")]  
  10.         public string firstName { getset; }  
  11.   
  12.         [Display(Name = "Last Name")]  
  13.         [Required(ErrorMessage = "Pleas Enter Your Last Name")]  
  14.         public string lastName { getset; }  
  15.   
  16.         [Display(Name = "Email Address")]  
  17.         [DataType(DataType.EmailAddress)]  
  18.         [Required(ErrorMessage = "Pleas Enter Your Email Address")]  
  19.         [RegularExpression(".+\\@.+\\..+", ErrorMessage = "Please Enater a Valid Email Address")]  
  20.         public string email { getset; }  
  21.   
  22.         [Required]  
  23.         [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]  
  24.         [DataType(DataType.Password)]  
  25.         [Display(Name = "Password")]  
  26.         public string Password { getset; }  
  27.   
  28.   
  29.         [Display(Name = "Mobile Number")]  
  30.         [Required(ErrorMessage = "Pleas Enter Your Mobile Number")]  
  31.         public string mobileNumber { getset; }  
  32.   
  33.         [Display(Name = "Address")]  
  34.         [Required(ErrorMessage = "Pleas Enter Your Address")]  
  35.         public string Address { getset; }  
  36.   
  37.         [Display(Name = "City")]  
  38.         [Required(ErrorMessage = "Pleas Enter Your City")]  
  39.         public string city { getset; }  
  40.   
  41.         [Display(Name = "State")]  
  42.         [Required(ErrorMessage = "Pleas Enter Your state")]  
  43.         public string state { getset; }  
  44.   
  45.         [Display(Name = "Zip Code")]  
  46.         [Required(ErrorMessage = "Pleas Enter Your Zip Code")]  
  47.         public int zipCode { getset; }  
  48.     } 

If I want to create a separate profile model for each role (customer/driver), I would include in each model what I want to save foreach user. But I don't know how would I create an action for that modelto generate all the information.?

Further, I want to have at some point the available rides to the driver so he can see which customer has requested him/her. Also, what rides the customer has requested in the customer profile.

I have a rides table in my database that has a relationship to the users/drivers table.it includes:

usersId, driversId, and Date (all as a primary key)
 
Thank You.
 

Answers (3)