Exemplo n.º 1
0
        public async Task <IActionResult> GetByUserAsync([FromRoute] int id)
        {
            var salaries = await _repositoryManager.SalaryRepository
                           .GetByUserAsync(id);

            return(Ok(salaries.Select(s => SalaryMapper.Map(s))));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> CreateAsync([FromBody] InSalaryDTO salaryDTO)
        {
            var salary = SalaryMapper.Map(salaryDTO);

            salary = _repositoryManager.SalaryRepository
                     .Create(salary);

            await _repositoryManager.SaveAsync();

            return(Ok(SalaryMapper.Map(salary)));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> UpdateAsync([FromBody] InUpdateSalaryDTO salaryDTO)
        {
            var salary = await _repositoryManager.SalaryRepository
                         .GetLastAsync(salaryDTO.UserId);

            if (salary == null)
            {
                return(NotFound());
            }

            salary.Update(salaryDTO.Amount, salaryDTO.DateOfAssignment);

            await _repositoryManager.SaveAsync();

            return(Ok(SalaryMapper.Map(salary)));
        }