This commit is contained in:
Ruidy Nemausat 2020-02-26 09:47:07 +01:00
parent d30bd3295a
commit 89078bb24a
3 changed files with 160 additions and 0 deletions

52
DTOs/AppUserDTO.cs Normal file
View file

@ -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<Activity> Activities { get; set; } = new List<Activity>();
public List<Project> Projects { get; set; } = new List<Project>();
public List<Ticket> Tickets { get; set; } = new List<Ticket>();
}
}

48
DTOs/ProjectDTO.cs Normal file
View file

@ -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<AppUser> Users { get; set; } = new List<AppUser>();
public List<Ticket> Tickets { get; set; } = new List<Ticket>();
public List<Activity> Activities { get; set; } = new List<Activity>();
public List<File> Files { get; set; } = new List<File>();
}
}

60
DTOs/TicketDTO.cs Normal file
View file

@ -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<Note> Notes { get; set; } = new List<Note>();
public List<Activity> Activities { get; set; } = new List<Activity>();
public List<File> Files { get; set; } = new List<File>();
public List<AppUser> Users { get; set; } = new List<AppUser>();
}
}