Commit 9c065223 authored by hasan khaddour's avatar hasan khaddour

Implement Project Controller

parent e9254581
......@@ -51,7 +51,8 @@ namespace PSManagement.Api.Controllers.Customers
var result = await _sender.Send(query);
return Ok(result);
return Ok(_mapper.Map<Result<CustomerRecord>>(result));
}
[HttpPost]
public async Task<IActionResult> CreateCustomer(CreateCustomerRequest request)
......
using AutoMapper;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PSManagement.Api.Controllers.ApiBase;
using PSManagement.Application.Projects.UseCases.Commands.AddAttachment;
using PSManagement.Application.Projects.UseCases.Commands.CreateProject;
using PSManagement.Application.Projects.UseCases.Queries.GetProject;
using PSManagement.Contracts.Projects.Requests;
using System;
using PSManagement.Contracts.Projects.Response;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Ardalis.Result;
using PSManagement.Application.Projects.UseCases.Queries.ListAllProject;
using PSManagement.Application.Projects.UseCases.Commands.AddParticipant;
using PSManagement.Application.Projects.UseCases.Commands.RemoveParticipant;
using PSManagement.Application.Projects.UseCases.Commands.AddProjectStep;
using PSManagement.Application.Projects.UseCases.Commands.ChangeProjectTeamLeader;
using PSManagement.Application.Projects.UseCases.Commands.ApproveProject;
using PSManagement.Application.Projects.UseCases.Queries.GetParticipants;
namespace PSManagement.Api.Controllers.Projects
{
......@@ -26,6 +33,92 @@ namespace PSManagement.Api.Controllers.Projects
_sender = sender;
}
[HttpGet]
public async Task<IActionResult> Get([FromQuery]ListAllProjectsRequest request)
{
var query = _mapper.Map<ListAllProjectsQuery>(request);
var result = _mapper.Map<Result<IEnumerable<ProjectResponse>>>(await _sender.Send(query));
return Ok(result);
}
[HttpGet("GetParticipants{id}")]
public async Task<IActionResult> GetParticipants(int id)
{
GetProjectParticipantsQuery query = new (id);
var result = await _sender.Send(query);
return Ok( _mapper.Map<Result<IEnumerable<EmployeeParticipateResponse>>>(result));
}
[HttpPost("ApproveProject")]
public async Task<IActionResult> ApproveProjectRequest(ApproveProjectRequest request)
{
var query = _mapper.Map<ApproveProjectCommand>(request);
var result = await _sender.Send(query);
return Ok(result);
}
[HttpPost("ChangeTeamLeader")]
public async Task<IActionResult> ChangeTeamLeader(ChangeProjectTeamLeaderRequest request)
{
var query = _mapper.Map<ChangeProjectTeamLeaderCommand>(request);
var result = await _sender.Send(query);
return Ok(result);
}
[HttpPost("AddProjectStep")]
public async Task<IActionResult> AddParticipant(AddProjectStepRequest request)
{
var query = _mapper.Map<AddProjectStepCommand>(request);
var result = await _sender.Send(query);
return Ok(result);
}
[HttpPost("RemoveParticipant")]
public async Task<IActionResult> RemoveParticipant(RemoveParticipantRequest request)
{
var query = _mapper.Map<RemoveParticipantCommand>(request);
var result = await _sender.Send(query);
return Ok(result);
}
[HttpPost("AddParticipant")]
public async Task<IActionResult> AddParticipant(AddParticipantRequest request)
{
var query = _mapper.Map<AddParticipantCommand>(request);
var result = await _sender.Send(query);
return Ok(result);
}
[HttpGet("{id}")]
public async Task<IActionResult> Get(int id)
{
var query = new GetProjectByIdQuery(id);
var result = await _sender.Send(query);
return Ok(_mapper.Map<Result<ProjectResponse>>(result));
}
[HttpPost]
public async Task<IActionResult> Post([FromBody] CreateProjectRequest request)
{
......
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PSManagement.Api.Controllers.ApiBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace PSManagement.Api.Controllers.Steps
{
[Route("api/[controller]")]
public class StepsController : APIController
{
}
}
using Microsoft.AspNetCore.Mvc;
using PSManagement.Api.Controllers.ApiBase;
namespace PSManagement.Api.Controllers.Tracks
{
[Route("api/[controller]")]
public class TracksController : APIController
{
}
}
......@@ -3,10 +3,19 @@ using PSManagement.Application.Customers.Common;
using PSManagement.Application.Customers.UseCases.Commands.AddContactInfo;
using PSManagement.Application.Customers.UseCases.Commands.CreateCustomer;
using PSManagement.Application.Customers.UseCases.Commands.UpdateCustomer;
using PSManagement.Application.Employees.Common;
using PSManagement.Application.Projects.Common;
using PSManagement.Application.Projects.UseCases.Commands.AddParticipant;
using PSManagement.Application.Projects.UseCases.Commands.AddProjectStep;
using PSManagement.Application.Projects.UseCases.Commands.ApproveProject;
using PSManagement.Application.Projects.UseCases.Commands.ChangeProjectTeamLeader;
using PSManagement.Application.Projects.UseCases.Commands.CreateProject;
using PSManagement.Application.Projects.UseCases.Commands.RemoveParticipant;
using PSManagement.Application.Projects.UseCases.Queries.ListAllProject;
using PSManagement.Contracts.Customers.Requests;
using PSManagement.Contracts.Customers.Responses;
using PSManagement.Contracts.Projects.Requests;
using PSManagement.Contracts.Projects.Response;
using PSManagement.SharedKernel.Utilities;
using System;
using System.Collections.Generic;
......@@ -38,7 +47,16 @@ namespace PSManagement.Api.Mappers
public ProjectMapperConfiguration()
{
CreateMap<CreateProjectRequest, CreateProjectCommand>().ReverseMap();
CreateMap<ListAllProjectsRequest, ListAllProjectsQuery>().ReverseMap();
CreateMap<ApproveProjectRequest, ApproveProjectCommand>().ReverseMap();
CreateMap<AddParticipantRequest, AddParticipantCommand>().ReverseMap();
CreateMap<AddProjectStepRequest, AddProjectStepCommand>().ReverseMap();
CreateMap<ChangeProjectTeamLeaderRequest, ChangeProjectTeamLeaderCommand>().ReverseMap();
CreateMap<RemoveParticipantRequest, RemoveParticipantCommand>().ReverseMap();
CreateMap<EmployeeResponse, EmployeeDTO>().ReverseMap();
CreateMap<EmployeeParticipateResponse, EmployeeParticipateDTO>().ReverseMap();
}
}
}
......@@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</PropertyGroup>
<ItemGroup>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment