Esempio n. 1
0
        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)));
        }
Esempio n. 2
0
        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()));
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 public IActionResult Get(long id)
 {
     return(Json(_employeeQuery.Get(id)));
 }
Esempio n. 5
0
        public async Task <ActionResult> Get([FromServices] IEmployeeQuery employeeQuery, CancellationToken cancellationToken)
        {
            var result = await employeeQuery.Get(cancellationToken);

            return(Ok(resumedEmployeeMapper.Map(result)));
        }