Beispiel #1
0
 public static Vacation GetVacationEntity(VacationForCreationDTO vacationDto)
 {
     return(new Vacation()
     {
         UserId = vacationDto.UserId,
         StartTime = vacationDto.StartTime,
         EndTime = vacationDto.EndTime
     });
 }
Beispiel #2
0
        public IActionResult PostVacation([FromBody] VacationForCreationDTO vacationFromRequest)
        {
            if (vacationFromRequest == null)
            {
                return(BadRequest());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            _repo.AddVacation(ModelsMapping.GetVacationEntity(vacationFromRequest));
            return(Ok());
        }
Beispiel #3
0
        public IActionResult PutVacation([FromBody] VacationForCreationDTO vacationFromRequest, int vacationId)
        {
            if (vacationFromRequest == null)
            {
                return(NotFound());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var vacation = _repo.GetVacation(vacationId);

            ValuesUpdater.UpdateVacationFromDto(vacation, vacationFromRequest);
            _repo.SaveChanges();

            return(Ok());
        }
Beispiel #4
0
 public static void UpdateVacationFromDto(Vacation vacationToUpdate, VacationForCreationDTO vacationWithUpdatedValues)
 {
     vacationToUpdate.UserId    = vacationWithUpdatedValues.UserId;
     vacationToUpdate.StartTime = vacationWithUpdatedValues.StartTime;
     vacationToUpdate.EndTime   = vacationWithUpdatedValues.EndTime;
 }