Ça va prendre un Update-Database

This commit is contained in:
MarcEricMartel
2022-11-04 15:22:24 -07:00
parent ca88b04811
commit 0b7b9689b1
7 changed files with 119 additions and 42 deletions

View File

@@ -3,7 +3,7 @@
namespace GrossesMitainesAPI.Models;
public class AddressModel {
[Key]
public int Id { get; set; }
public int Id { get; set; } = 0;
[Required, Range(1, int.MaxValue)]
public int CivicNumber { get; set; }
public string? Appartment { get; set; }
@@ -18,5 +18,16 @@ public class AddressModel {
// 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")]
public string PostalCode { get; set; }
public AddressModel() { }
public AddressModel(SendInvoiceModel sinv) {
CivicNumber = sinv.CivicNumber;
Appartment = sinv.Appartment;
Street = sinv.Street;
City = sinv.City;
Province = sinv.Province;
Country = sinv.Country;
PostalCode = sinv.PostalCode;
}
}

View File

@@ -37,5 +37,13 @@ public class InvoiceModel {
[Required]
public AddressModel ShippingAddress { get; set; }
public InStates Status { get; set; } = InStates.Confirmed;
public InvoiceModel() { }
public InvoiceModel(SendInvoiceModel sinv) {
FirstName = sinv.FirstName;
LastName = sinv.LastName;
PhoneNumber = sinv.PhoneNumber;
EmailAddress = sinv.EmailAddress;
}
}

View File

@@ -0,0 +1,29 @@
using System.ComponentModel.DataAnnotations;
namespace GrossesMitainesAPI.Models;
public class SendInvoiceModel {
[Required, MinLength(2), MaxLength(30)]
public string FirstName { get; set; }
[Required, MinLength(1), MaxLength(30)]
public string LastName { get; set; }
[Required, Phone]
public string PhoneNumber { get; set; }
[Required, EmailAddress]
public string EmailAddress { 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")]
public string PostalCode { get; set; }
public Dictionary<int, uint> ProdQuant { get; set; }
}