Renvoit du rôle au frontend avec Get Login (UPDATE-DATABASE)
This commit is contained in:
22
GrossesMitaines/GrossesMitainesAPI/Models/AddressModel.cs
Normal file
22
GrossesMitaines/GrossesMitainesAPI/Models/AddressModel.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GrossesMitainesAPI.Models;
|
||||
public class AddressModel {
|
||||
[Key]
|
||||
public int Id { 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; }
|
||||
}
|
||||
|
@@ -1,12 +1,36 @@
|
||||
using GrossesMitainesAPI.Data;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace GrossesMitainesAPI.Models;
|
||||
public class InvoiceModel {
|
||||
public InventoryUser Account { get; set; }
|
||||
public DateTime PurchaseDate { get; set; }
|
||||
public Dictionary<Product, int> Products { get; set; }
|
||||
public InventoryUser.Address BillingAddress { get; set; }
|
||||
public InventoryUser.Address ShippingAddress { get; set; }
|
||||
public class ProductInvoice {
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public ProductModel Product { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
[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; }
|
||||
public InventoryUser? LinkedAccount { get; set; }
|
||||
public DateTime PurchaseDate { get; } = DateTime.Now;
|
||||
[Required]
|
||||
public List<ProductInvoice> Products { get; set; }
|
||||
|
||||
//[Required, Column("BillingAddress")]
|
||||
//public AddressModel BillingAddress { get; set; }
|
||||
[Required]
|
||||
public AddressModel ShippingAddress { get; set; }
|
||||
public bool Canceled { get; set; } = false;
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace GrossesMitainesAPI.Models;
|
||||
|
||||
public class Product {
|
||||
public class ProductModel {
|
||||
public enum States {
|
||||
Available,
|
||||
BackOrder,
|
@@ -1,4 +1,4 @@
|
||||
using static GrossesMitainesAPI.Models.Product;
|
||||
using static GrossesMitainesAPI.Models.ProductModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GrossesMitainesAPI.Models;
|
||||
@@ -13,7 +13,7 @@ public class ProductViewModel {
|
||||
public States Status { get; set; } = States.Available;
|
||||
public string? ImageName { get; set; }
|
||||
|
||||
public ProductViewModel(Product prod) {
|
||||
public ProductViewModel(ProductModel prod) {
|
||||
this.Id = prod.Id;
|
||||
this.Title = prod.Title;
|
||||
this.Category = prod.Category;
|
||||
|
@@ -1,20 +1,27 @@
|
||||
using GrossesMitainesAPI.Data;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace GrossesMitainesAPI.Models;
|
||||
public class ReturnUserViewModel {
|
||||
public string Username { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public bool EmailConfirmed { get; set; }
|
||||
public bool PhoneConfirmed { get; set; }
|
||||
public bool TwoFactorEnable { get; set; }
|
||||
public string Role { get; set; }
|
||||
|
||||
public ReturnUserViewModel(InventoryUser user) {
|
||||
public ReturnUserViewModel(InventoryUser user, string role) {
|
||||
Username = user.UserName;
|
||||
Email = user.Email;
|
||||
Phone = user.PhoneNumber;
|
||||
EmailConfirmed = user.EmailConfirmed;
|
||||
PhoneConfirmed = user.PhoneNumberConfirmed;
|
||||
TwoFactorEnable = user.TwoFactorEnabled;
|
||||
FirstName = user.FirstName;
|
||||
LastName = user.LastName;
|
||||
Role = role;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user