public async Task <IActionResult> PostYearSalary([FromBody] YearSalary yearSalary)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.YearSalary.Add(yearSalary);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (YearSalaryExists(yearSalary.Year, yearSalary.IdEmployee))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetYearSalary", new { year = yearSalary.Year, idEmployee = yearSalary.IdEmployee }, yearSalary));
        }
        public async Task <IActionResult> PutYearSalary([FromRoute] int oldYear, [FromRoute] int idEmployee, [FromBody] YearSalary yearSalary)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (idEmployee != yearSalary.IdEmployee)
            {
                return(BadRequest());
            }

            // if client changed "year", create new row and delete the original row
            // otherwise just update
            if (oldYear != yearSalary.Year)
            {
                _context.YearSalary.Add(yearSalary);
                var oldSalaryRow = await _context.YearSalary.FindAsync(oldYear, idEmployee);

                _context.YearSalary.Remove(oldSalaryRow);
            }
            else
            {
                _context.Entry(yearSalary).State = EntityState.Modified;
            }

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!YearSalaryExists(oldYear, idEmployee))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            // return updated data
            return(Ok(yearSalary));
        }