private static void CheckAndHandleReservations() { List <Reservation> reservations = reservationsService.GetReservations(); if (reservations.Count == 0) { return; } lock (reservations) { List <Reservation> reservationsForRemoving = new List <Reservation>(); Zone zone; ParkingPlace parkingPlace; foreach (Reservation reservation in reservations) { if (reservation.GetEndDateTimeServer() < DateTime.Now) { zone = zonesService.GetZone(reservation.ParkingPlace.Zone.Id); lock (zone) { parkingPlace = zone.GetParkingPlace(reservation.ParkingPlace.Id); lock (parkingPlace) { parkingPlace.Status = ParkingPlaceStatus.EMPTY; } zone.Version++; zone.AddParkingPlaceChange(parkingPlace.Id, parkingPlace.Status); } reservation.User.Reservation = null; reservation.User.AddViolation(true); reservationsForRemoving.Add(reservation); } } if (reservationsForRemoving.Count > 0) { reservations.RemoveAll(item => reservationsForRemoving.Contains(item)); } } }
public IActionResult Get() { try { List <Reservation> reservations = _reservationService.GetReservations(); List <ReservationDto> result = new List <ReservationDto>(); foreach (Reservation res in reservations) { WorkDay workDay = _workDaysService.GetWorkDay(res.WorkDayId); ReservationDto dto = _mapper.Map <ReservationDto>( res, opt => { opt.Items["workDay"] = workDay; }); result.Add(dto); } return(Ok(result)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public async Task <ActionResult <IEnumerable <ReservationItem> > > Get() { return(Ok(await _service.GetReservations())); }
public ActionResult <IEnumerable <ReservationViewModel> > GetReservations() { return(_reservationsService.GetReservations()); }