Esempio n. 1
0
        public async Task <EmploymentConfirmation> UpdateEmployment(Guid employeeId, Guid carStationId, EmploymentPutBody employmentPutBody)
        {
            var employment = await _context.Set <EmployeeCarStation>().FirstOrDefaultAsync(e => e.EmployeeId == employeeId && e.CarStationId == carStationId);

            if (employment == null)
            {
                return(null);
            }

            employment.EmployeeId   = employmentPutBody.EmployeeId;
            employment.CarStationId = employmentPutBody.CarStationId;
            employment.StartDate    = employmentPutBody.StartDate;
            employment.EndDate      = employmentPutBody.EndDate;

            await _context.SaveChangesAsync();

            _logger.LogInformation("UpdateEmploymentAsync() Executed!");
            return(await Task.FromResult(_mapper.Map <EmploymentConfirmation>(employment)));
        }
        public async Task <ActionResult <EmploymentConfirmation> > PutEmployment(Guid carStationId, Guid employeeId, [FromBody] EmploymentPutBody employmentPutBody)
        {
            var updatedEmploymentConfirmation = await _service.UpdateEmployment(employeeId, carStationId, employmentPutBody);

            if (updatedEmploymentConfirmation == null)
            {
                return(BadRequest());
            }
            return(Ok(updatedEmploymentConfirmation));
        }