public async Task <ActionResult> Get(int id, [FromServices] IEmployeeQuery employeeQuery, CancellationToken cancellationToken) { var result = await employeeQuery.Get(id, cancellationToken); if (result == null) { return(NotFound()); } return(Ok(detailedEmployeeMapper.Map(result))); }
public async Task <Wage> Handle(ChangeSalaryCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { throw new BusinessException("Change salary command is invalid"); } var employee = await employeeQuery.Get(request.EmployeeId, cancellationToken); employee.ChangeSalary(request.CountUnit, request.Amount); return(await wageRepository.Create(employee.Id, employee.Wages.Last())); }
public async Task <bool> Handle(UpdateEmployeeNameCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { throw new BusinessException("Update employee name command is invalid"); } var employee = await employeeQuery.Get(request.Id); employee.SetName(request.Name); await employeeRepository.Update(employee); return(true); }
public IActionResult Get(long id) { return(Json(_employeeQuery.Get(id))); }
public async Task <ActionResult> Get([FromServices] IEmployeeQuery employeeQuery, CancellationToken cancellationToken) { var result = await employeeQuery.Get(cancellationToken); return(Ok(resumedEmployeeMapper.Map(result))); }