From da468f28531f0852db786a386951e9f827b28e34 Mon Sep 17 00:00:00 2001 From: carteronm Date: Thu, 2 Oct 2025 17:11:00 +0200 Subject: [PATCH 1/3] Project4 Adding entities --- PyroFetes/Models/Availability.cs | 12 ++++++++++++ PyroFetes/Models/Communication.cs | 13 +++++++++++++ PyroFetes/Models/Contact.cs | 18 ++++++++++++++++++ PyroFetes/Models/Customer.cs | 15 +++++++++++++++ PyroFetes/Models/CustomerContact.cs | 13 +++++++++++++ PyroFetes/Models/CustomerType.cs | 11 +++++++++++ PyroFetes/Models/ExperienceLevel.cs | 9 +++++++++ PyroFetes/Models/HistoryOfApproval.cs | 10 ++++++++++ PyroFetes/Models/Provider.cs | 14 ++++++++++++++ PyroFetes/Models/ProviderContact.cs | 12 ++++++++++++ PyroFetes/Models/ProviderType.cs | 9 +++++++++ PyroFetes/Models/Staff.cs | 10 ++++++++++ PyroFetes/Models/StaffAvailability.cs | 12 ++++++++++++ PyroFetes/Models/StaffContact.cs | 12 ++++++++++++ PyroFetes/Models/StaffHistoryOfApproval.cs | 12 ++++++++++++ 15 files changed, 182 insertions(+) create mode 100644 PyroFetes/Models/Availability.cs create mode 100644 PyroFetes/Models/Communication.cs create mode 100644 PyroFetes/Models/Contact.cs create mode 100644 PyroFetes/Models/Customer.cs create mode 100644 PyroFetes/Models/CustomerContact.cs create mode 100644 PyroFetes/Models/CustomerType.cs create mode 100644 PyroFetes/Models/ExperienceLevel.cs create mode 100644 PyroFetes/Models/HistoryOfApproval.cs create mode 100644 PyroFetes/Models/Provider.cs create mode 100644 PyroFetes/Models/ProviderContact.cs create mode 100644 PyroFetes/Models/ProviderType.cs create mode 100644 PyroFetes/Models/Staff.cs create mode 100644 PyroFetes/Models/StaffAvailability.cs create mode 100644 PyroFetes/Models/StaffContact.cs create mode 100644 PyroFetes/Models/StaffHistoryOfApproval.cs diff --git a/PyroFetes/Models/Availability.cs b/PyroFetes/Models/Availability.cs new file mode 100644 index 0000000..a727c3a --- /dev/null +++ b/PyroFetes/Models/Availability.cs @@ -0,0 +1,12 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Availability +{ + [Key] public int Id { get; set; } + [Required] public string AvailabilityDate { get; set; } + [Required] public string DeliveryDate { get; set; } + [Required] public string ExpirationDate { get; set; } + [Required] public string RenewallDate { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Communication.cs b/PyroFetes/Models/Communication.cs new file mode 100644 index 0000000..7c3e284 --- /dev/null +++ b/PyroFetes/Models/Communication.cs @@ -0,0 +1,13 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Communication +{ + [Key] public int Id { get; set; } + [Required] public string Calling { get; set; } + [Required] public string Email { get; set; } + [Required] public string Meeting { get; set; } + + //REL +} \ No newline at end of file diff --git a/PyroFetes/Models/Contact.cs b/PyroFetes/Models/Contact.cs new file mode 100644 index 0000000..87385bc --- /dev/null +++ b/PyroFetes/Models/Contact.cs @@ -0,0 +1,18 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Contact +{ + [Key] public int Id { get; set; } + [Required] public string LastName { get; set; } + [Required] public string FirstName { get; set; } + [Required] public string Email { get; set; } + [Required] public string PhoneNumber { get; set; } + [Required] public string Address { get; set; } + [Required] public string Role { get; set; } + + //RELATIONS DE CON LA + public int CommunicationID { get; set; } + public Communication? Communication { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Customer.cs b/PyroFetes/Models/Customer.cs new file mode 100644 index 0000000..3e7139a --- /dev/null +++ b/PyroFetes/Models/Customer.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Customer +{ + [Key] public int Id { get; set; } + [Required] public string? Note { get; set; } + //Les relations + public int CustomerTypeId { get; set; } + public CustomerType? CustomerType { get; set; } + + public int ContactId { get; set; } + public Contact? Contact { get; set; } +} diff --git a/PyroFetes/Models/CustomerContact.cs b/PyroFetes/Models/CustomerContact.cs new file mode 100644 index 0000000..dff5fb2 --- /dev/null +++ b/PyroFetes/Models/CustomerContact.cs @@ -0,0 +1,13 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ContactId), nameof(CustomerId))] +public class CustomerContact +{ + public int CustomerId { get; set; } + public Customer? Customer { get; set; } + public int ContactId { get; set; } + public Contact? Contact { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/CustomerType.cs b/PyroFetes/Models/CustomerType.cs new file mode 100644 index 0000000..28fc14d --- /dev/null +++ b/PyroFetes/Models/CustomerType.cs @@ -0,0 +1,11 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class CustomerType +{ + [Key] public int Id { get; set; } + [Required] public string? Price { get; set; } + //RELATIONS PTN + public List? Customers { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/ExperienceLevel.cs b/PyroFetes/Models/ExperienceLevel.cs new file mode 100644 index 0000000..8a2bb93 --- /dev/null +++ b/PyroFetes/Models/ExperienceLevel.cs @@ -0,0 +1,9 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class ExperienceLevel +{ + [Key] public int Id { get; set; } + [Required] public string Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/HistoryOfApproval.cs b/PyroFetes/Models/HistoryOfApproval.cs new file mode 100644 index 0000000..4e05886 --- /dev/null +++ b/PyroFetes/Models/HistoryOfApproval.cs @@ -0,0 +1,10 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class HistoryOfApproval +{ + [Key] public int Id { get; set; } + [Required] public string ExpirationDate { get; set; } + [Required] public string DeliveryDate { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Provider.cs b/PyroFetes/Models/Provider.cs new file mode 100644 index 0000000..fdfc566 --- /dev/null +++ b/PyroFetes/Models/Provider.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Provider +{ + [Key] public int Id { get; set; } + [Required] public decimal Price { get; set; } + + //Relations + + public int ProviderID { get; set; } + public ProviderType? ProviderType { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/ProviderContact.cs b/PyroFetes/Models/ProviderContact.cs new file mode 100644 index 0000000..cdfefb3 --- /dev/null +++ b/PyroFetes/Models/ProviderContact.cs @@ -0,0 +1,12 @@ +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ContactId), nameof(ProviderId))] +public class ProviderContact +{ + public int ProviderId { get; set; } + public Provider? Provider { get; set; } + public int ContactId { get; set; } + public Contact? Contact { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/ProviderType.cs b/PyroFetes/Models/ProviderType.cs new file mode 100644 index 0000000..ac620c9 --- /dev/null +++ b/PyroFetes/Models/ProviderType.cs @@ -0,0 +1,9 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class ProviderType +{ + [Key] public int Id { get; set; } + [Required] public string Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Staff.cs b/PyroFetes/Models/Staff.cs new file mode 100644 index 0000000..fef94d9 --- /dev/null +++ b/PyroFetes/Models/Staff.cs @@ -0,0 +1,10 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Staff +{ + [Key] public int Id { get; set; } + [Required] public string F4T2NumberApproval { get; set; } + [Required] public string F4T2ExpirationDate { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/StaffAvailability.cs b/PyroFetes/Models/StaffAvailability.cs new file mode 100644 index 0000000..3ba0732 --- /dev/null +++ b/PyroFetes/Models/StaffAvailability.cs @@ -0,0 +1,12 @@ +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(AvailabilityId), nameof(StaffId))] +public class StaffAvailability +{ + public int StaffId { get; set; } + public Staff? Staff { get; set; } + public int AvailabilityId { get; set; } + public Availability? Availability { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/StaffContact.cs b/PyroFetes/Models/StaffContact.cs new file mode 100644 index 0000000..3fb3f87 --- /dev/null +++ b/PyroFetes/Models/StaffContact.cs @@ -0,0 +1,12 @@ +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ContactId), nameof(StaffId))] +public class StaffContact +{ + public int StaffId { get; set; } + public Staff? Staff { get; set; } + public int ContactId { get; set; } + public Contact? Contact { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/StaffHistoryOfApproval.cs b/PyroFetes/Models/StaffHistoryOfApproval.cs new file mode 100644 index 0000000..3937064 --- /dev/null +++ b/PyroFetes/Models/StaffHistoryOfApproval.cs @@ -0,0 +1,12 @@ +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(HistoryOfApprovalId), nameof(StaffId))] +public class StaffHistoryOfApproval +{ + public int StaffId { get; set; } + public Staff? Staff { get; set; } + public int HistoryOfApprovalId { get; set; } + public HistoryOfApproval? HistoryOfApproval { get; set; } +} \ No newline at end of file From 52521908b7cc54465fd9ca46d87a75b971f20cb1 Mon Sep 17 00:00:00 2001 From: sanchezvem Date: Fri, 3 Oct 2025 16:53:18 +0100 Subject: [PATCH 2/3] Change type of date parameters (string => DateOnly) --- PyroFetes/Models/Availability.cs | 8 ++++---- PyroFetes/Models/Communication.cs | 6 +++--- PyroFetes/Models/Contact.cs | 16 +++++++++------- PyroFetes/Models/Customer.cs | 1 + PyroFetes/Models/CustomerType.cs | 4 ++-- PyroFetes/Models/ExperienceLevel.cs | 2 +- PyroFetes/Models/HistoryOfApproval.cs | 4 ++-- PyroFetes/Models/Provider.cs | 2 +- PyroFetes/Models/ProviderType.cs | 2 +- PyroFetes/Models/Staff.cs | 6 +++--- 10 files changed, 27 insertions(+), 24 deletions(-) diff --git a/PyroFetes/Models/Availability.cs b/PyroFetes/Models/Availability.cs index a727c3a..5d85e0d 100644 --- a/PyroFetes/Models/Availability.cs +++ b/PyroFetes/Models/Availability.cs @@ -5,8 +5,8 @@ namespace PyroFetes.Models; public class Availability { [Key] public int Id { get; set; } - [Required] public string AvailabilityDate { get; set; } - [Required] public string DeliveryDate { get; set; } - [Required] public string ExpirationDate { get; set; } - [Required] public string RenewallDate { get; set; } + [Required] public string? AvailabilityDate { get; set; } + [Required] public DateOnly DeliveryDate { get; set; } + [Required] public DateOnly ExpirationDate { get; set; } + [Required] public DateOnly RenewallDate { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Communication.cs b/PyroFetes/Models/Communication.cs index 7c3e284..6faa91a 100644 --- a/PyroFetes/Models/Communication.cs +++ b/PyroFetes/Models/Communication.cs @@ -5,9 +5,9 @@ namespace PyroFetes.Models; public class Communication { [Key] public int Id { get; set; } - [Required] public string Calling { get; set; } - [Required] public string Email { get; set; } - [Required] public string Meeting { get; set; } + [Required] public string? Calling { get; set; } + [Required] public string? Email { get; set; } + [Required] public string? Meeting { get; set; } //REL } \ No newline at end of file diff --git a/PyroFetes/Models/Contact.cs b/PyroFetes/Models/Contact.cs index 87385bc..8b6a6cf 100644 --- a/PyroFetes/Models/Contact.cs +++ b/PyroFetes/Models/Contact.cs @@ -5,14 +5,16 @@ namespace PyroFetes.Models; public class Contact { [Key] public int Id { get; set; } - [Required] public string LastName { get; set; } - [Required] public string FirstName { get; set; } - [Required] public string Email { get; set; } - [Required] public string PhoneNumber { get; set; } - [Required] public string Address { get; set; } - [Required] public string Role { get; set; } + [Required, MaxLength(100)] public string? LastName { get; set; } + [Required, MaxLength(100)] public string? FirstName { get; set; } + [Required] public string? Email { get; set; } + [Required] public string? PhoneNumber { get; set; } + [Required] public string? Address { get; set; } + [Required] public string? ZipCode { get; set; } + [Required] public string? City { get; set; } + [Required] public string? Role { get; set; } //RELATIONS DE CON LA - public int CommunicationID { get; set; } + public int CommunicationId { get; set; } public Communication? Communication { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Customer.cs b/PyroFetes/Models/Customer.cs index 3e7139a..31f0203 100644 --- a/PyroFetes/Models/Customer.cs +++ b/PyroFetes/Models/Customer.cs @@ -6,6 +6,7 @@ public class Customer { [Key] public int Id { get; set; } [Required] public string? Note { get; set; } + //Les relations public int CustomerTypeId { get; set; } public CustomerType? CustomerType { get; set; } diff --git a/PyroFetes/Models/CustomerType.cs b/PyroFetes/Models/CustomerType.cs index 28fc14d..3e24483 100644 --- a/PyroFetes/Models/CustomerType.cs +++ b/PyroFetes/Models/CustomerType.cs @@ -5,7 +5,7 @@ namespace PyroFetes.Models; public class CustomerType { [Key] public int Id { get; set; } - [Required] public string? Price { get; set; } - //RELATIONS PTN + [Required] public decimal Price { get; set; } + public List? Customers { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/ExperienceLevel.cs b/PyroFetes/Models/ExperienceLevel.cs index 8a2bb93..41a1879 100644 --- a/PyroFetes/Models/ExperienceLevel.cs +++ b/PyroFetes/Models/ExperienceLevel.cs @@ -5,5 +5,5 @@ namespace PyroFetes.Models; public class ExperienceLevel { [Key] public int Id { get; set; } - [Required] public string Label { get; set; } + [Required] public string? Label { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/HistoryOfApproval.cs b/PyroFetes/Models/HistoryOfApproval.cs index 4e05886..8c85ef8 100644 --- a/PyroFetes/Models/HistoryOfApproval.cs +++ b/PyroFetes/Models/HistoryOfApproval.cs @@ -5,6 +5,6 @@ namespace PyroFetes.Models; public class HistoryOfApproval { [Key] public int Id { get; set; } - [Required] public string ExpirationDate { get; set; } - [Required] public string DeliveryDate { get; set; } + [Required] public DateOnly ExpirationDate { get; set; } + [Required] public DateOnly DeliveryDate { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Provider.cs b/PyroFetes/Models/Provider.cs index fdfc566..f48e2c3 100644 --- a/PyroFetes/Models/Provider.cs +++ b/PyroFetes/Models/Provider.cs @@ -9,6 +9,6 @@ public class Provider //Relations - public int ProviderID { get; set; } + public int ProviderId { get; set; } public ProviderType? ProviderType { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/ProviderType.cs b/PyroFetes/Models/ProviderType.cs index ac620c9..4c8f70c 100644 --- a/PyroFetes/Models/ProviderType.cs +++ b/PyroFetes/Models/ProviderType.cs @@ -5,5 +5,5 @@ namespace PyroFetes.Models; public class ProviderType { [Key] public int Id { get; set; } - [Required] public string Label { get; set; } + [Required] public string? Label { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Staff.cs b/PyroFetes/Models/Staff.cs index fef94d9..c405e21 100644 --- a/PyroFetes/Models/Staff.cs +++ b/PyroFetes/Models/Staff.cs @@ -1,10 +1,10 @@ -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; namespace PyroFetes.Models; public class Staff { [Key] public int Id { get; set; } - [Required] public string F4T2NumberApproval { get; set; } - [Required] public string F4T2ExpirationDate { get; set; } + [Required] public string? F4T2NumberApproval { get; set; } + [Required] public string? F4T2ExpirationDate { get; set; } } \ No newline at end of file From 65725922f6cf35d09ec3c89279085f4269e1da74 Mon Sep 17 00:00:00 2001 From: sanchezvem Date: Fri, 3 Oct 2025 16:58:36 +0100 Subject: [PATCH 3/3] Delete Staff.cs --- PyroFetes/Models/Staff.cs | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 PyroFetes/Models/Staff.cs diff --git a/PyroFetes/Models/Staff.cs b/PyroFetes/Models/Staff.cs deleted file mode 100644 index c405e21..0000000 --- a/PyroFetes/Models/Staff.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace PyroFetes.Models; - -public class Staff -{ - [Key] public int Id { get; set; } - [Required] public string? F4T2NumberApproval { get; set; } - [Required] public string? F4T2ExpirationDate { get; set; } -} \ No newline at end of file