Esempio n. 1
0
        public async Task CancelUserReservation(UserReservation reservation)
        {
            var state = await _authenticationStateProvider.GetAuthenticationStateAsync();

            var userId = (await _userManager.GetUserAsync(state.User)).Id;
            await _bookingStorage.RemoveReservation(userId, reservation);

            OnBookingsChanged();
        }
Esempio n. 2
0
        public async Task RemoveReservation(string userId, UserReservation reservation)
        {
            await using var dbCtx = new BookingsDbContext(_dbContextOptions);
            var itemToRemove = await dbCtx.UserReservations.FirstOrDefaultAsync(res =>
                                                                                res.UserId == userId && res.TeamId == reservation.TeamId && res.StartTime == reservation.StartTime);

            if (itemToRemove == null)
            {
                return;
            }
            dbCtx.UserReservations.Remove(itemToRemove);
            await dbCtx.SaveChangesAsync();
        }
Esempio n. 3
0
        public async Task AddReservation(string userId, UserReservation reservation)
        {
            await using var dbCtx = new BookingsDbContext(_dbContextOptions);
            var reservationEntity = new UserReservationEntity
            {
                StartTime = reservation.StartTime,
                TeamId    = reservation.TeamId,
                UserId    = userId,
                EndTime   = reservation.StartTime + _teamService.GetTeam(reservation.TeamId).Duration
            };

            dbCtx.UserReservations.Add(reservationEntity);
            await dbCtx.SaveChangesAsync();
        }
Esempio n. 4
0
        public async Task <int> GetLoggedOnUserPositionForReservedSession(UserReservation userReservation)
        {
            var allReservations = await _bookingStorage.GetReservationsForSession(userReservation.TeamId, userReservation.StartTime);

            return(allReservations.IndexOf(await GetLoggedOnUserId()));
        }