diff --git a/DTOs/AppUserDTO.cs b/DTOs/AppUserDTO.cs new file mode 100644 index 0000000..b2009d3 --- /dev/null +++ b/DTOs/AppUserDTO.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using TicketManager.Models; + +namespace TicketManager.DTO +{ + public class AppUserDTO + { + public AppUserDTO(AppUser user) + { + Id = user.Id; + FirstName = user.FirstName; + LastName = user.LastName; + Presentation = user.Presentation; + Email = user.Email; + Phone = user.Phone; + Created_at = user.Created_at; + Picture = user.Picture; + Activities = user.Activities; + Projects = user.GetProjects(); + Tickets = user.GetTickets(); + } + + public Guid Id { get; set; } + + public string FirstName { get; set; } + + public string LastName { get; set; } + + public string FullName => $"{FirstName} {LastName}"; + + public string Presentation { get; set; } + + [DataType(DataType.EmailAddress)] + public string Email { get; set; } + + [DataType(DataType.PhoneNumber)] + public string Phone { get; set; } + + [DataType(DataType.Date)] + public DateTime Created_at { get; private set; } = DateTime.Now; + + public string Picture { get; set; } + + public List Activities { get; set; } = new List(); + + public List Projects { get; set; } = new List(); + + public List Tickets { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/DTOs/ProjectDTO.cs b/DTOs/ProjectDTO.cs new file mode 100644 index 0000000..ba8d098 --- /dev/null +++ b/DTOs/ProjectDTO.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using TicketManager.Models; + +namespace TicketManager.DTO +{ + public class ProjectDTO + { + public ProjectDTO(Project project) + { + Id = project.Id; + Title = project.Title; + Description = project.Description; + CreatedAt = project.CreatedAt; + Progression = project.Progression; + Status = project.Status.ToString(); + Manager = project.Manager; + Users = project.GetMembers(); + Tickets = project.Tickets; + Activities = project.Activities; + Files = project.Files; + } + + public int Id { get; set; } + + public string Title { get; set; } + + public string Description { get; set; } + + public DateTime CreatedAt { get; private set; } = DateTime.Now; + + public DateTime PlannedEnding { get; set; } + + public decimal Progression { get; set; } + + public string Status { get; set; } + + public AppUser Manager { get; set; } + + public List Users { get; set; } = new List(); + + public List Tickets { get; set; } = new List(); + + public List Activities { get; set; } = new List(); + + public List Files { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/DTOs/TicketDTO.cs b/DTOs/TicketDTO.cs new file mode 100644 index 0000000..cdacb99 --- /dev/null +++ b/DTOs/TicketDTO.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using TicketManager.Models; + +namespace TicketManager.DTO +{ + public class TicketDTO + { + public TicketDTO(Ticket ticket) + { + Id = ticket.Id; + Title = ticket.Title; + Description = ticket.Description; + CreatedAt = ticket.CreatedAt; + PlannedEnding = ticket.PlannedEnding; + Status = ticket.Status.ToString(); + Impact = ticket.Impact.ToString(); + Difficulty = ticket.Difficulty.ToString(); + Category = ticket.Category.ToString(); + CreatorId = ticket.CreatorId; + Project = ticket.Project; + Notes = ticket.Notes; + Activities = ticket.Activities; + Files = ticket.Files; + Users = ticket.GetAssignees(); + } + public int Id { get; set; } + + public string Title { get; set; } + + public string Description { get; set; } + + [DataType(DataType.Date)] + public DateTime CreatedAt { get; private set; } + + [DataType(DataType.Date)] + public DateTime PlannedEnding { get; set; } + + public string Status { get; set; } + + public string Impact { get; set; } + + public string Difficulty { get; set; } + + public string Category { get; set; } + + public Guid CreatorId { get; set; } + + public Project Project { get; set; } + + public List Notes { get; set; } = new List(); + + public List Activities { get; set; } = new List(); + + public List Files { get; set; } = new List(); + + public List Users { get; set; } = new List(); + } +} \ No newline at end of file