Beispiel #1
0
 private void NotifyExpired(Request request)
 {
     request.State = RequestState.Expired;
     using (var uzDbContext = new UzDbContext()) {
         uzDbContext.Entry(request).State = EntityState.Modified;
         uzDbContext.SaveChanges();
     }
 }
Beispiel #2
0
        public IHttpActionResult RequestPlace([FromBody] RequestDto requestDto)
        {
            if (!ModelState.IsValid)
            {
                return(ValidationError());
            }
            Request request = Mapper.Map <RequestDto, Request>(requestDto);

            using (var context = new UzDbContext()) {
                context.Requests.Add(request);
                context.SaveChanges();
            }
            return(Ok());
        }
Beispiel #3
0
        private async void NotifyFoundAsync(BookPlacesResponse bookingResult, Request request)
        {
            var reservation = new Reservation {
                Token            = Guid.NewGuid().ToString(),
                RequestId        = request.Id,
                BookingTimestamp = DateTime.Now.Ticks,
                SessionId        = bookingResult.Cookies["_gv_sessid"]
            };

            request.State = RequestState.Found;
            using (var uzDbContext = new UzDbContext()) {
                uzDbContext.Reservations.Add(reservation);
                uzDbContext.Entry(request).State = EntityState.Modified;
                uzDbContext.SaveChanges();
            }

            Response mailSendingResponse = await MailSender.Send(request, reservation.Token, reservation.SessionId);
        }
Beispiel #4
0
        public async System.Threading.Tasks.Task <IHttpActionResult> RequestPlaceAsync(string token)
        {
            if (!ModelState.IsValid)
            {
                return(ValidationError());
            }
            Reservation reservation;

            using (var context = new UzDbContext()) {
                reservation = await context.Reservations.Where(reserv => reserv.Token == token)
                              .Include(reserv => reserv.Request)
                              .FirstOrDefaultAsync();
            }
            if (reservation == null)
            {
                return(NotFound());
            }
            ReservationDto reservationDto = Mapper.Map <Reservation, ReservationDto>(reservation);

            return(Json(reservationDto));
        }
Beispiel #5
0
 private Request[] GetRequests()
 {
     using (var uzDbContext = new UzDbContext()) {
         return(uzDbContext.Requests.Where(request => request.State == RequestState.Requested).ToArray());
     }
 }