Commit 4f8f60d1 authored by hasan khaddour's avatar hasan khaddour

fix mapping issues

parent 9c6c50b6
......@@ -25,7 +25,7 @@ namespace PSManagement.Api.Controllers.Customers
[Route("api/[controller]")]
[Authorize]
public class CustomersController : APIController
{
{
private readonly IMediator _sender;
private readonly IMapper _mapper;
......
......@@ -8,6 +8,7 @@ using PSManagement.Application.Contracts.Providers;
using PSManagement.Application.Contracts.SyncData;
using PSManagement.Application.Employees.UseCases.Commands.UpdateEmployeeWorkHours;
using PSManagement.Application.Employees.UseCases.Queries.GetAvailableEmployees;
using PSManagement.Application.Employees.UseCases.Queries.GetDepartments;
using PSManagement.Application.Employees.UseCases.Queries.GetEmployeeById;
using PSManagement.Application.Employees.UseCases.Queries.GetEmployeesByFilter;
using PSManagement.Application.Employees.UseCases.Queries.GetEmployeeTrackHistory;
......@@ -32,11 +33,13 @@ namespace PSManagement.Api.Controllers.Employees
public EmployeesController(
ISyncEmployeesService syncEmployeesService,
IMapper mapper,
IMediator sender)
IMediator sender,
IEmployeesProvider employeesProvider)
{
_syncEmployeesService = syncEmployeesService;
_mapper = mapper;
_sender = sender;
_employeesProvider = employeesProvider;
}
......@@ -70,6 +73,17 @@ namespace PSManagement.Api.Controllers.Employees
return HandleResult(_mapper.Map<Result<IEnumerable<EmployeeResponse>>>(result));
}
[HttpGet("Departments")]
public async Task<IActionResult> GetDepartments()
{
var query = new GetDepartmentsQuery();
var result = await _sender.Send(query);
return HandleResult(_mapper.Map<Result<IEnumerable<DepartmentResponse>>>(result));
}
[HttpGet("EmployeeParticipations")]
public async Task<IActionResult> GetEmployeeParticipations([FromQuery] GetEmployeeParticipationRequest request)
......
......@@ -182,10 +182,10 @@ namespace PSManagement.Api.Controllers.Projects
return HandleResult(result);
}
[HttpPost("CompleteProject/{id}")]
public async Task<IActionResult> PostCompleteProjectRequest(int id )
[HttpPost("CompleteProject")]
public async Task<IActionResult> PostCompleteProjectRequest(CompleteProjectRequest request )
{
var query = new CompleteProjectCommand(id);
var query = _mapper.Map<CompleteProjectCommand>(request);
var result = await _sender.Send(query);
......@@ -194,6 +194,16 @@ namespace PSManagement.Api.Controllers.Projects
#endregion project state operations
[HttpPost("ChangeParticipation")]
public async Task<IActionResult> PostChangePArticipation(ChangeEmployeeParticipationRequest request)
{
var query = _mapper.Map<ChangeEmployeeParticipationCommand>(request);
var result = await _sender.Send(query);
return HandleResult(result);
}
[HttpGet("{id}")]
public async Task<IActionResult> Get(int id)
......
using Ardalis.Result;
using AutoMapper;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PSManagement.Api.Controllers.ApiBase;
using PSManagement.Application.ProjectsTypes.UseCases.Commands.CreateNewType;
using PSManagement.Application.ProjectsTypes.UseCases.Queries.GetProjectsTypes;
using PSManagement.Application.ProjectsTypes.UseCases.Queries.GetTypeById;
using PSManagement.Contracts.ProjectsTypes.Request;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace PSManagement.Api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ProjectsTypesController : APIController
{
private readonly IMediator _sender;
private readonly IMapper _mapper;
public ProjectsTypesController(IMediator sender, IMapper mapper)
{
_sender = sender;
_mapper = mapper;
}
[HttpGet]
public async Task<IActionResult> Get()
{
var query = new GetProjectsTypesQuery();
var result = _mapper.Map<Result<IEnumerable<ProjectTypeResponse>>>(await _sender.Send(query));
return HandleResult(result);
}
[HttpGet("{id}")]
public async Task<IActionResult> Get(int id)
{
var query = new GetTypeByIdQuery(id);
var result = await _sender.Send(query);
return HandleResult(_mapper.Map<Result<ProjectTypeResponse>>(result));
}
[HttpPost]
public async Task<IActionResult> Post(CreateNewTypeRequest request)
{
var command = _mapper.Map<CreateNewTypeCommand>(request);
var result = await _sender.Send(command);
if (result.IsSuccess)
{
var query = new GetTypeByIdQuery(result.Value);
var response = await _sender.Send(query);
return HandleResult(_mapper.Map<Result<ProjectTypeResponse>>(response));
}
else
{
return HandleResult(result);
}
}
[HttpDelete("{id}")]
public async Task<IActionResult> Delete(int id)
{
var command = new RemoveTypeCommand(id);
var result = await _sender.Send(command);
return HandleResult(result);
}
[HttpPut("{id}")]
public async Task<IActionResult> Put(int id, UpdateTypeCommand request)
{
if (id != request.Id)
{
return Problem();
}
var command = _mapper.Map<UpdateTypeCommand>(request);
var result = await _sender.Send(command);
return HandleResult(result);
}
}
}
......@@ -14,6 +14,7 @@ using PSManagement.Application.Tracks.UseCaes.Queries.GetEmployeesTrack;
using PSManagement.Application.Tracks.UseCaes.Queries.GetStepsTrack;
using PSManagement.Application.Tracks.UseCaes.Queries.GetTrackById;
using PSManagement.Application.Tracks.UseCaes.Queries.GetTracksByProject;
using PSManagement.Application.Tracks.UseCaes.Queries.GetUncompletedTracks;
using PSManagement.Contracts.Tracks.Requests;
using PSManagement.Contracts.Tracks.Response;
using System.Collections.Generic;
......@@ -53,6 +54,15 @@ namespace PSManagement.Api.Controllers.Tracks
return HandleResult(result);
}
[HttpGet("UnCompleted")]
public async Task<IActionResult> GetUnCompleted()
{
var query = new GetUnCompletedTracksQuery();
var result = _mapper.Map<Result<IEnumerable<TrackResponse>>>(await _sender.Send(query));
return HandleResult(result);
}
[HttpGet("GetEmployeesTrack/{id}")]
public async Task<IActionResult> GetEmployeesTrack([FromRoute] int id)
......
......@@ -18,5 +18,8 @@
},
"EmpoyeesSyncJobSettings": {
"SyncIntervalInMinutes": 60
},
"FileServiceSettings": {
"AvailableExtension": ["png","pdf"]
}
}
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