Skip to content

Commit

Permalink
Trying to make csharp like the usage of uow in tourservice
Browse files Browse the repository at this point in the history
  • Loading branch information
ReallyWeirdCat committed Nov 17, 2024
1 parent dd22010 commit f10e09a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public IQueryable<EntertaimentDto> GetEntertaiments(GetEntertaimentsRequest getE
IQueryable<Entertaiment> entertaiments;
if(getEntertaiments.Categories!=null)
{
var entertainments = _unitOfWork.Entertaiments.GetAll()
entertainments = _unitOfWork.Entertaiments.GetAll()
.Where(e =>
_unitOfWork.EntertaimentCategories.GetAll()
.Where(ec => getEntertaiments.Categories.Contains(ec.CategoryId))
Expand All @@ -81,7 +81,7 @@ public IQueryable<EntertaimentDto> GetEntertaiments(GetEntertaimentsRequest getE
}
else
{
var entertainments = _unitOfWork.Entertaiments.GetAll()
entertainments = _unitOfWork.Entertaiments.GetAll()
.Where(e =>
e.Rating >= getEntertaiments.MinimalRating && e.Rating <= getEntertaiments.MaximalRating &&
e.Price >= getEntertaiments.MinimalPrice && e.Price <= getEntertaiments.MaximalPrice &&
Expand Down
17 changes: 8 additions & 9 deletions TourService/Services/TourService/TourService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,22 @@ public IQueryable<TourDto> GetTours(GetToursRequest getTours)
{
tours = _unitOfWork.Tours.GetAll()
.Where(t =>
_unitOfWork.TourCategories.GetAll()
.Where(tc => getTours.Categories.Contains(tc.CategoryId))
.Select(tc => tc.TourId)
.Contains(t.Id)
)
.Where(t => t.Rating >= getTours.MinimalRating && t.Rating <= getTours.MaximalRating)
.Where(t => t.Price >= getTours.MinimalPrice && t.Price <= getTours.MaximalPrice)
.Distinct()
t.Rating >= getTours.MinimalRating &&
t.Rating <= getTours.MaximalRating &&
t.Price >= getTours.MinimalPrice &&
t.Price <= getTours.MaximalPrice &&
_unitOfWork.TourCategories.GetAll(new FindOptions())
.Any(tc => tc.TourId == t.Id && getTours.Categories.Contains(tc.CategoryId)))
.Skip((getTours.Page - 1) * 10)
.Take(10)
.ToList();

}
else if(getTours.TourTags!=null)
{
tours = _unitOfWork.Tours.GetAll()
.Where(t =>
_unitOfWork.TourTags.GetAll()
_unitOfWork.TourTags.GetAll(new FindOptions())
.Where(tt => getTours.TourTags.Contains(tt.TagId))
.Select(tt => tt.TourId)
.Contains(t.Id)
Expand Down

0 comments on commit f10e09a

Please sign in to comment.