This commit is contained in:
Ruidy Nemausat 2020-02-26 09:47:00 +01:00
parent 1856c60bca
commit d30bd3295a
8 changed files with 14 additions and 210 deletions

10
.gitignore vendored
View file

@ -1,14 +1,14 @@
bin/
obj/
.vs/
.vscode/
Migrations/
app.db*
.DS_Store
app.db
bin/
obj/
app.db*
Data/Interfaces
Data/UnitOfWork.cs
Data/*Repository.cs
Migrations/
Properties/
# client
client/src/pages/TestPage.tsx

View file

@ -1,49 +0,0 @@
using System.Threading.Tasks;
using TicketManager.Models;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
namespace TicketManager.Data
{
public class ProjectRepository : GenericRepository<Project>, IProjectRepository
{
private readonly IQueryable<Project> _query;
public ProjectRepository(AppDbContext context) : base(context)
{
_query = _dbSet
.Include(p => p.Assignments).ThenInclude(a => a.User)
.Include(p => p.Tickets)
.Include(p => p.Manager)
.Include(p => p.Files)
// .AsNoTracking()
;
}
public override async Task<Project> Get(int id)
{
return await _query.FirstOrDefaultAsync(p => p.Id == id);
}
public override async Task<IEnumerable<Project>> List()
{
return await _query.ToListAsync();
}
public bool Exists(int id)
{
return _dbSet.Any(e => e.Id == id);
}
public async Task<IEnumerable<AppUser>> GetMembers(int id)
{
Project project = await Get(id);
return project.GetMembers();
}
public async Task SetMembers(int id, List<AppUser> usersToAdd)
{
Project project = await Get(id);
project.SetMembers(usersToAdd);
}
}
}

View file

@ -1,53 +0,0 @@
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>();
}
}

View file

@ -1,47 +0,0 @@
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>();
}
}

View file

@ -1,51 +0,0 @@
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>();
}
}

View file

@ -20,7 +20,7 @@
"TicketManager": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"launchUrl": "/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},

View file

@ -41,9 +41,9 @@ namespace TicketManager
options.EnableSensitiveDataLogging(true); //Remove in production.
}
);
services.AddScoped<IProjectRepository, ProjectRepository>();
services.AddScoped<IAppUserRepository, AppUserRepository>();
services.AddScoped<ITicketRepository, TicketRepository>();
// services.AddScoped<IProjectRepository, ProjectRepository>();
// services.AddScoped<IAppUserRepository, AppUserRepository>();
// services.AddScoped<ITicketRepository, TicketRepository>();
services.AddAuthentication(options =>
{

View file

@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<PropertyGroup >
<PropertyGroup>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup>
@ -30,6 +30,10 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="5.0.0" />
<PackageReference Include="Xunit" Version="2.4.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Folder Include="client\" />