eh lala
This commit is contained in:
@@ -40,13 +40,33 @@ public class UserController : Controller {
|
||||
#region API Methods
|
||||
[HttpPost, AllowAnonymous]
|
||||
public ActionResult<ReturnUserViewModel> Post(SignUpUserModel sign) {
|
||||
int x = 0;
|
||||
InventoryUser usr;
|
||||
try {
|
||||
usr = new(sign);
|
||||
usr = new() {
|
||||
FirstName = sign.FirstName,
|
||||
LastName = sign.LastName,
|
||||
Email = sign.Email,
|
||||
PhoneNumber = sign.Phone
|
||||
};
|
||||
} catch (Exception e){
|
||||
return BadRequest($"Erreur utilisateur: {e.Message}");
|
||||
}
|
||||
|
||||
try {
|
||||
usr.Adresses.Add(new AddressModel() {
|
||||
CivicNumber = sign.CivicNumber,
|
||||
Appartment = sign.Appartment,
|
||||
Street = sign.Street,
|
||||
City = sign.City,
|
||||
Province = sign.Province,
|
||||
Country = sign.Country,
|
||||
PostalCode = sign.PostalCode
|
||||
});
|
||||
} catch (Exception e) {
|
||||
return BadRequest($"Erreur adresse: {e.Message}");
|
||||
}
|
||||
|
||||
try {
|
||||
usr.PasswordHash = new PasswordHasher<InventoryUser>().HashPassword(usr, sign.Password);
|
||||
} catch (Exception e){
|
||||
|
@@ -19,7 +19,6 @@ public class InventoryUser : IdentityUser {
|
||||
NormalizedEmail = sign.Email.ToUpper();
|
||||
Email = sign.Email;
|
||||
PhoneNumber = sign.Phone;
|
||||
Adresses = sign.Adresses;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,19 @@ public class SignUpUserModel {
|
||||
public string Phone { get; set; }
|
||||
[Required]
|
||||
public string Password { get; set; }
|
||||
public List<AddressModel> Adresses { get; set; }
|
||||
[Required, Range(1, int.MaxValue)]
|
||||
public int CivicNumber { get; set; }
|
||||
public string? Appartment { get; set; }
|
||||
[Required, MinLength(3), MaxLength(50)]
|
||||
public string Street { get; set; }
|
||||
[Required, MinLength(4), MaxLength(50)]
|
||||
public string City { get; set; }
|
||||
[Required, MaxLength(3)]
|
||||
public string Province { get; set; }
|
||||
[Required, MinLength(4), MaxLength(30)]
|
||||
public string Country { get; set; }
|
||||
// Source pour regex: https://stackoverflow.com/questions/15774555/efficient-regex-for-canadian-postal-code-function
|
||||
//[Required, RegularExpression(@"/^[ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ -]?\d[ABCEGHJ-NPRSTV-Z]\d$/i")] TODO: REGEX
|
||||
public string PostalCode { get; set; }
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user