public CityStatisticsDto GetForCityEscapeRoomsStatistics(string city) { var escapeRooms = _escapeRoomRepository.GetEscapeRooms().Where(e => e.City == city).ToList(); if (!escapeRooms.Any()) { throw new BadValueException("Escape rooms for this city does not exists"); } var reviews = _reviewRepository.GetReviews().ToList(); return(new CityStatisticsDto { EscapeRoomsNumber = escapeRooms.Count, AverageGameTime = _escapeRoomCityStatisticProvider.CalculateAverageGameTime(escapeRooms), AveragePrice = _escapeRoomCityStatisticProvider.CalculateAveragePrice(escapeRooms), AverageRating = _escapeRoomCityStatisticProvider.CalculateAverageRating(escapeRooms, reviews), FamousTypes = _escapeRoomCityStatisticProvider.CalculateFamousEscapeRoomsTypes(escapeRooms) }); }
public IEnumerable <EscapeRoomDto> GetAll() { var allEscapeRooms = _escapeRoomRepository.GetEscapeRooms(); return(allEscapeRooms.ToList().ConvertAll(e => new EscapeRoomDto { Category = e.Category, Description = e.Description, Email = e.Email, ForAdult = e.ForAdult, Name = e.Name, PhoneNumber = e.PhoneNumber, MaxPeopleNumber = e.MaxPeopleNumber, Time = e.Time, Price = e.Price, City = e.City, BuildingNumber = e.BuildingNumber, Street = e.Street, Id = e.EscapeRoomId })); }
public IEnumerable <ReviewForUserDto> GetByUserId(int id) { var allReviews = _reviewRepository.GetReviews(); var escapeRooms = _escapeRoomRepository.GetEscapeRooms(); return(allReviews.ToList().Where(e => e.UserId == id).ToList().ConvertAll(e => new ReviewForUserDto { Content = e.Content, Rating = e.Rating, Title = e.Title, EscapeRoom = escapeRooms.FirstOrDefault(a => a.EscapeRoomId == e.EscapeRoomId)?.Name, Id = e.Id })); }