void ReleaseDesignerOutlets() { if (DestinationBar != null) { DestinationBar.Dispose(); DestinationBar = null; } if (ListView != null) { ListView.Dispose(); ListView = null; } if (RestaurantMap != null) { RestaurantMap.Dispose(); RestaurantMap = null; } if (YasssBootun != null) { YasssBootun.Dispose(); YasssBootun = null; } }
void ReleaseDesignerOutlets() { if (DestinationBar != null) { DestinationBar.Dispose(); DestinationBar = null; } if (RestaurantMap != null) { RestaurantMap.Dispose(); RestaurantMap = null; } if (ResultList != null) { ResultList.Dispose(); ResultList = null; } }
public IList <TimeRange> GetUnavailableTimeRanges(int restaurantId, int participantsCount, TimeRange timeRange) { var restaurant = _dbContext.Restaurants .AsNoTracking() .Include(r => r.Map) .ThenInclude(m => m.Tables) .FirstOrDefault(r => r.Id == restaurantId); restaurant = restaurant ?? throw new RestaurantNotFoundException(); // TODO: Remove theses lines because the new restaurants should already have a default map assigned at creation time if (restaurant.Map == null) { var newRestaurantMap = new RestaurantMap { RestaurantId = restaurant.Id }; _dbContext.RestaurantMaps.Add(newRestaurantMap); _dbContext.SaveChanges(); restaurant.Map = newRestaurantMap; } var tables = _mapper.Map <List <TableModel> >(restaurant.Map.Tables); if (!DoesParticipantsFitToTables(tables, participantsCount)) { return(new List <TimeRange> { timeRange }); } // TODO: improve this to be done in one query bool isReservationInRange(Reservation res) => res.StartTime <timeRange.End && res.EndTime> timeRange.Start; var reservations = _dbContext.Reservations .AsNoTracking() .Include(r => r.ReservedTables) .ThenInclude(rt => rt.Table) .Where(r => r.RestaurantId == restaurantId) .Where(isReservationInRange) .ToList(); var detailedReservations = _mapper.Map <IList <ReservationDetailedModel> >(reservations); var tablesAvailabilityList = GetTablesAvailabilityList(tables, detailedReservations); var unavailableTimeRanges = new List <TimeRange>(); foreach (var tablesAvailability in tablesAvailabilityList) { if (!DoesParticipantsFitToTables(tablesAvailability.FreeTables, participantsCount)) { unavailableTimeRanges.Add(tablesAvailability.Range); } } var midnight = timeRange.Start.Date; while (midnight < timeRange.End) { unavailableTimeRanges.Add(new TimeRange { Start = midnight, End = midnight + TimeSpan.FromHours(7) }); unavailableTimeRanges.Add(new TimeRange { Start = midnight + TimeSpan.FromHours(22), End = midnight + TimeSpan.FromHours(24) }); midnight += TimeSpan.FromDays(1); } return(unavailableTimeRanges); }