diff --git a/Api/Controllers/EventCommentController.cs b/Api/Controllers/EventCommentController.cs index f0288f8a01b014a8cbe29e5ae1aff0bacd381fbf..ca56b60ce4db373661fd817e228459d64eb03b84 100644 --- a/Api/Controllers/EventCommentController.cs +++ b/Api/Controllers/EventCommentController.cs @@ -3,10 +3,11 @@ using BusinessLayer.DTOs.EventComment; using BusinessLayer.Services.EventCommentService; using Microsoft.AspNetCore.Mvc; using BusinessLayer.Utils.Filters; +using Mapster; namespace Api.Controllers { - [Route("/[controller]")] + [Route("/api/[controller]")] [ApiController] public class EventCommentController : Controller { @@ -26,13 +27,16 @@ namespace Api.Controllers return NotFound(); } - return Ok(comment); + return Ok(comment.Adapt<EventCommentModel>()); } [HttpGet] public async Task<IActionResult> GetEventComments([FromQuery] EventCommentFilter filter, [FromQuery] int limit = 0, [FromQuery] int offset = 0) { - var comments = await _eventCommentService.GetCommentsAsync(filter, limit, offset, includeUser: true, includeEvent: true, includeChildren: true); + var comments = (await _eventCommentService + .GetCommentsAsync(filter, limit, offset, includeUser: true, includeEvent: true, includeChildren: true)) + .Select(c => c.Adapt<EventCommentModel>()) + .ToList(); return Ok(comments); } @@ -53,7 +57,10 @@ namespace Api.Controllers return NotFound("Poster or Event not found, or parent comment does not exist."); } - return CreatedAtAction(nameof(GetEventCommentById), new { commentId = result.Id }, result); + return CreatedAtAction( + nameof(GetEventCommentById), + new { commentId = result.Id }, + result.Adapt<EventCommentModel>()); } [HttpPatch("{commentId:guid}")] @@ -70,7 +77,7 @@ namespace Api.Controllers return NotFound(); } - return Ok(result); + return Ok(result.Adapt<EventCommentModel>()); } [HttpDelete("{commentId:guid}")] diff --git a/Api/Controllers/EventController.cs b/Api/Controllers/EventController.cs index 3c304753d8dcc69342d32634c21ac263626c6aad..4036e1159bc8232eb55b8f8a81238e8673fb265b 100644 --- a/Api/Controllers/EventController.cs +++ b/Api/Controllers/EventController.cs @@ -3,11 +3,12 @@ using BusinessLayer.DTOs.Event; using BusinessLayer.Services.EventService; using BusinessLayer.Utils.Filters; using BusinessLayer.Utils.Ordering; +using Mapster; using Microsoft.AspNetCore.Mvc; namespace Api.Controllers { - [Route("/[controller]")] + [Route("/api/[controller]")] [ApiController] public class EventController : Controller { @@ -27,14 +28,16 @@ namespace Api.Controllers return NotFound(); } - return Ok(eventEntity); + return Ok(eventEntity.Adapt<EventModel>()); } [HttpGet] public async Task<IActionResult> GetEvents([FromQuery] EventFilter filter, EventOrdering eventOrder = EventOrdering.DateAscending, [FromQuery] int limit = 0, [FromQuery] int offset = 0) { var events = await _eventService.GetEventsAsync(filter, eventOrder, limit, offset); - return Ok(events); + return Ok(events + .Select(e => e.Adapt<EventInfoModel>()) + .ToList()); } [HttpPost] @@ -50,12 +53,13 @@ namespace Api.Controllers }; var result = await _eventService.CreateEventAsync(createDTO); - if (result is null) - { - return NotFound("Creator or restaurant does not exist."); - } - return CreatedAtAction(nameof(GetEventById), new { eventId = result.Id }, result); + return result is null + ? NotFound("Creator or restaurant does not exist.") + : CreatedAtAction( + nameof(GetEventById), + new { eventId = result.Id }, + result.Adapt<EventModel>()); } [HttpPatch("{eventId:guid}")] @@ -69,18 +73,20 @@ namespace Api.Controllers }; var result = await _eventService.UpdateEventAsync(eventId, updateDTO); + if (result is null) { return NotFound(); } - return Ok(result); + return Ok(result.Adapt<EventModel>()); } [HttpDelete("{eventId:guid}")] public async Task<IActionResult> DeleteEvent([FromRoute] Guid eventId) { var success = await _eventService.DeleteEventAsync(eventId); + if (!success) { return NotFound(); diff --git a/Api/Controllers/EventParticipantController.cs b/Api/Controllers/EventParticipantController.cs index 2ddf5c563172ac3fbb29290602675b14248e3a9d..cd05a4b6f0ef7070669d16499a7b1dd6c9a3edb9 100644 --- a/Api/Controllers/EventParticipantController.cs +++ b/Api/Controllers/EventParticipantController.cs @@ -2,11 +2,12 @@ using BusinessLayer.DTOs.EventParticipant; using BusinessLayer.Services.EventParticipantService; using BusinessLayer.Utils.Filters; +using Mapster; using Microsoft.AspNetCore.Mvc; namespace Api.Controllers { - [Route("/[controller]")] + [Route("/api/[controller]")] [ApiController] public class EventParticipantController : Controller { @@ -26,14 +27,16 @@ namespace Api.Controllers return NotFound(); } - return Ok(participant); + return Ok(participant.Adapt<EventParticipantModel>()); } [HttpGet] public async Task<IActionResult> GetEventParticipants([FromQuery] EventParticipantFilter filter, [FromQuery] int limit = 0, [FromQuery] int offset = 0) { var participants = await _eventParticipantService.GetParticipantsAsync(filter, limit, offset); - return Ok(participants); + return Ok(participants + .Select(p => p.Adapt<EventParticipantModel>()) + .ToList()); } [HttpPost] @@ -47,16 +50,21 @@ namespace Api.Controllers }; var result = await _eventParticipantService.CreateParticipantAsync(createDTO); + if (result is null) { return NotFound("User or event does not exist, or participant already exists."); } - return CreatedAtAction(nameof(GetEventParticipantById), new { userId = result.User.Id, eventId = result.Event.Id }, result); + return CreatedAtAction( + nameof(GetEventParticipantById), + new { userId = result.User.Id, eventId = result.Event.Id }, + result.Adapt<EventParticipantModel>()); } [HttpPatch("{participantId:guid}")] - public async Task<IActionResult> UpdateEventParticipant([FromRoute] Guid participantId, [FromBody] EventParticipantUpdateModel data) + public async Task<IActionResult> UpdateEventParticipant([FromRoute] Guid participantId, + [FromBody] EventParticipantUpdateModel data) { var updateDTO = new EventParticipantUpdateDTO { @@ -64,24 +72,16 @@ namespace Api.Controllers }; var result = await _eventParticipantService.UpdateParticipantAsync(participantId, updateDTO); - if (result is null) - { - return NotFound(); - } - return Ok(result); + return result is null ? NotFound() : Ok(result.Adapt<EventParticipantModel>()); } [HttpDelete("{participantId:guid}")] public async Task<IActionResult> DeleteEventParticipant([FromRoute] Guid participantId) { - var success = await _eventParticipantService.DeleteParticipantAsync(participantId); - if (!success) - { - return NotFound(); - } - - return Ok(); + return await _eventParticipantService.DeleteParticipantAsync(participantId) + ? Ok() + : NotFound(); } } } diff --git a/Api/Controllers/LocationController.cs b/Api/Controllers/LocationController.cs index 11a3f24e5eac03ec09f09e10e3965b31b280f01a..735a88844961ed16370b54c72a6366f63e5bbf2a 100644 --- a/Api/Controllers/LocationController.cs +++ b/Api/Controllers/LocationController.cs @@ -1,13 +1,15 @@ +using Api.Models.Location; using BusinessLayer.DTOs.Location; using BusinessLayer.Services.LocationService; using BusinessLayer.Utils.Filters; using BusinessLayer.Utils.Ordering; using DAL.Models; +using Mapster; using Microsoft.AspNetCore.Mvc; namespace Api.Controllers { - [Route("/[controller]")] + [Route("/api/[controller]")] [ApiController] public class LocationController(ILocationService locationService) : Controller { @@ -18,11 +20,10 @@ namespace Api.Controllers public async Task<ActionResult<Location>> GetLocationById([FromRoute] Guid restaurantId) { var location = await _locationService.GetLocationAsync(restaurantId); - if (location == null) - { - return NotFound("Location not found."); - } - return Ok(location); + + return location is null + ? NotFound("Location not found.") + : Ok(location.Adapt<LocationModel>()); } [HttpGet] @@ -39,14 +40,17 @@ namespace Api.Controllers limit, offset, ids); - return Ok(locations); + + return Ok(locations + .Select(l => l.Adapt<LocationModel>()) + .ToList()); } [HttpPatch] [Route("{restaurantId:guid}")] public async Task<IActionResult> UpdateLocation( [FromRoute] Guid restaurantId, - [FromBody] LocationUpdateDto data) + [FromBody] LocationUpdateModel data) { if (data.Country is null && data.City is null && data.Address is null && data.Zipcode is null) @@ -73,12 +77,12 @@ namespace Api.Controllers { return BadRequest("Zipcode cannot be set to an empty string."); } - var location = await _locationService.UpdateLocationAsync(restaurantId, data); - if (location == null) - { - return NotFound("Location not found."); - } - return Ok(location); + + var location = await _locationService.UpdateLocationAsync(restaurantId, data.Adapt<LocationUpdateDto>()); + + return location is null + ? NotFound("Location not found.") + : Ok(location.Adapt<LocationModel>()); } } } diff --git a/Api/Controllers/RestaurantController.cs b/Api/Controllers/RestaurantController.cs index a2295cf04f8b99cbbaede4f521fc0a648f0fcf85..32b38062d3dd3156746937441835326472ec47ae 100644 --- a/Api/Controllers/RestaurantController.cs +++ b/Api/Controllers/RestaurantController.cs @@ -4,10 +4,12 @@ using BusinessLayer.Services.RestaurantMaintainerService; using BusinessLayer.Utils.Filters; using BusinessLayer.Utils.Ordering; using Microsoft.AspNetCore.Mvc; +using Api.Models.Restaurant; +using Mapster; namespace Api.Controllers { - [Route("/[controller]")] + [Route("/api/[controller]")] [ApiController] public class RestaurantController( IRestaurantService restaurantService, @@ -22,7 +24,7 @@ namespace Api.Controllers { var restaurant = await _restaurantService.GetRestaurantAsync(restaurantId); return restaurant == null - ? Ok(restaurant) + ? Ok(restaurant.Adapt<RestaurantDetailModel>()) : NotFound("Restaurant not found"); } @@ -40,15 +42,18 @@ namespace Api.Controllers limit, offset, ids); - return Ok(restaurants); + + return Ok(restaurants + .Select(r => r.Adapt<RestaurantModel>()) + .ToList()); } [HttpPost] - public async Task<IActionResult> CreateRestaurant([FromBody] RestaurantCreateDto data) + public async Task<IActionResult> CreateRestaurant([FromBody] RestaurantCreateModel data) { - var restaurant = await _restaurantService.CreateRestaurantAsync(data); + var restaurant = await _restaurantService.CreateRestaurantAsync(data.Adapt<RestaurantCreateDto>()); return restaurant == null - ? Ok(restaurant) + ? Ok(restaurant.Adapt<RestaurantDetailModel>()) : NotFound("Maintainer not found"); } @@ -56,7 +61,7 @@ namespace Api.Controllers [Route("{restaurantId:guid}")] public async Task<IActionResult> UpdateRestaurant( [FromRoute] Guid restaurantId, - [FromBody] RestaurantUpdateDto data) + [FromBody] RestaurantUpdateModel data) { if (data.Name is null && data.About is null && data.Email is null && data.Web is null @@ -73,9 +78,9 @@ namespace Api.Controllers return BadRequest("Category can't be set to empty string."); } - var restaurant = await _restaurantService.UpdateRestaurantAsync(restaurantId, data); + var restaurant = await _restaurantService.UpdateRestaurantAsync(restaurantId, data.Adapt<RestaurantUpdateDto>()); return restaurant == null - ? Ok(restaurant) + ? Ok(restaurant.Adapt<RestaurantDetailModel>()) : NotFound("Restaurant not found"); } diff --git a/Api/Controllers/ReviewAggregateResultController.cs b/Api/Controllers/ReviewAggregateResultController.cs index eb4cfb07efd33cbe0e62172bb155e6a172808b47..959070b562f7a0d7f766bce45d9bd4b489efcc46 100644 --- a/Api/Controllers/ReviewAggregateResultController.cs +++ b/Api/Controllers/ReviewAggregateResultController.cs @@ -1,10 +1,12 @@ -using BusinessLayer.Services.ReviewAggregateService; +using Api.Models.ReviewAggregate; +using BusinessLayer.Services.ReviewAggregateService; +using Mapster; using Microsoft.AspNetCore.Mvc; namespace Api.Controllers { [ApiController] - [Route("/[controller]")] + [Route("/api/[controller]")] public class ReviewAggregateResultController : Controller { private readonly IReviewAggregateResultService _service; @@ -21,14 +23,15 @@ namespace Api.Controllers var aggregate = await _service.GetAggregateByIdAsync(restaurantId); return aggregate is null ? NotFound("Data not found, try again later.") - : Ok(aggregate); + : Ok(aggregate.Adapt<ReviewAggregateModel>()); } [HttpGet] public async Task<IActionResult> GetAggregates([FromQuery] string orderBy = "", [FromQuery] int limit = 0, [FromQuery] int offset = 0) { - return Ok(await _service.GetAggregatesAsync(orderBy, limit, offset, false)); + var aggregates = await _service.GetAggregatesAsync(orderBy, limit, offset, false); + return Ok(aggregates.Select(a => a.Adapt<ReviewAggregateModel>()).ToList()); } // The other operations do not make much sense here. This entity is tied to restaurant. diff --git a/Api/Controllers/ReviewCommentController.cs b/Api/Controllers/ReviewCommentController.cs index 85e05b2fd97be7bdc195d1be3ef8ea36a67800d0..b04bba076e6a36c92aa6b8d2d0c392c8b1d9fabf 100644 --- a/Api/Controllers/ReviewCommentController.cs +++ b/Api/Controllers/ReviewCommentController.cs @@ -1,12 +1,14 @@ -using BusinessLayer.DTOs.ReviewComment; +using Api.Models.ReviewComment; +using BusinessLayer.DTOs.ReviewComment; using BusinessLayer.Services.ReviewCommentService; using BusinessLayer.Utils.Filters; +using Mapster; using Microsoft.AspNetCore.Mvc; namespace Api.Controllers { [ApiController] - [Route("/[controller]")] + [Route("/api/[controller]")] public class ReviewCommentController : Controller { private readonly IReviewCommentService _service; @@ -24,35 +26,41 @@ namespace Api.Controllers return comment is null ? NotFound("Comment does not exist.") - : Ok(comment); + : Ok(comment.Adapt<ReviewCommentModel>()); } [HttpGet] public async Task<IActionResult> GetReviewComments([FromQuery] ReviewCommentFilter filter, [FromQuery] int limit = 0, [FromQuery] int offset = 0) { - return Ok(await _service.GetCommentsAsync(filter, limit, offset)); + var comments = await _service.GetCommentsAsync(filter, limit, offset); + return Ok(comments + .Select(c => c.Adapt<ReviewCommentModel>()) + .ToList()); } [HttpPost] - public async Task<IActionResult> CreateReviewComment([FromBody] ReviewCommentCreateDTO data) + public async Task<IActionResult> CreateReviewComment([FromBody] ReviewCommentCreateModel data) { - var comment = await _service.CreateCommentAsync(data); + var comment = await _service.CreateCommentAsync(data.Adapt<ReviewCommentCreateDTO>()); return comment is null ? NotFound("The review or the poster of the comment was not found.") - : CreatedAtAction(nameof(CreateReviewComment), comment); + : CreatedAtAction( + nameof(CreateReviewComment), + new { commentId = comment.Id }, + comment.Adapt<ReviewCommentModel>()); } [HttpPatch] [Route("{commentId:guid}")] - public async Task<IActionResult> UpdateReviewComment([FromRoute] Guid commentId, [FromBody] ReviewCommentUpdateDTO data) + public async Task<IActionResult> UpdateReviewComment([FromRoute] Guid commentId, [FromBody] ReviewCommentUpdateModel data) { - var comment = await _service.UpdateCommentAsync(commentId, data); + var comment = await _service.UpdateCommentAsync(commentId, data.Adapt<ReviewCommentUpdateDTO>()); return comment is null ? NotFound("The comment does not exist.") - : Ok(comment); + : Ok(comment.Adapt<ReviewCommentModel>()); } /** diff --git a/Api/Controllers/ReviewController.cs b/Api/Controllers/ReviewController.cs index 3601ab96baa0bdb4fdc57817b8c77fbbafa38f8a..d87c747e1d6af34816de1e2d41c9ecc044a5cc84 100644 --- a/Api/Controllers/ReviewController.cs +++ b/Api/Controllers/ReviewController.cs @@ -3,11 +3,12 @@ using BusinessLayer.DTOs.Review; using BusinessLayer.Services.ReviewService; using BusinessLayer.Utils.Filters; using BusinessLayer.Utils.Ordering; +using Mapster; using Microsoft.AspNetCore.Mvc; namespace Api.Controllers { - [Route("/[controller]")] + [Route("/api/[controller]")] [ApiController] public class ReviewController : Controller { @@ -28,7 +29,7 @@ namespace Api.Controllers return NotFound(); } - return Ok(review); + return Ok(review.Adapt<ReviewDetailModel>()); } [HttpGet] @@ -36,23 +37,30 @@ namespace Api.Controllers [FromQuery] ReviewOrdering orderBy, [FromQuery] int limit = 0, [FromQuery] int offset = 0) { - return Ok(await _service.GetReviewsAsync(filter, orderBy, limit, offset)); + var reviews = await _service.GetReviewsAsync(filter, orderBy, limit, offset); + + return Ok(reviews + .Select(r => r.Adapt<ReviewModel>()) + .ToList()); } [HttpPost] - public async Task<IActionResult> CreateReview([FromBody] ReviewCreateDTO data) + public async Task<IActionResult> CreateReview([FromBody] ReviewCreateModel data) { - var review = await _service.CreateReviewAsync(data); + var review = await _service.CreateReviewAsync(data.Adapt<ReviewCreateDTO>()); return review is null ? NotFound("User or Restaurant does not exist.") - : CreatedAtAction(nameof(CreateReview), review); + : CreatedAtAction( + nameof(CreateReview), + new { reviewId = review.Id }, + review.Adapt<ReviewDetailModel>()); } [HttpPatch] [Route("{reviewId:guid}")] public async Task<IActionResult> UpdateReview([FromRoute] Guid reviewId, - [FromBody] ReviewUpdateDTO data) + [FromBody] ReviewUpdateModel data) { if (UpdateEmpty(data)) { @@ -64,11 +72,11 @@ namespace Api.Controllers return BadRequest("Review content cannot be empty."); } - var review = await _service.UpdateReviewAsync(reviewId, data); + var review = await _service.UpdateReviewAsync(reviewId, data.Adapt<ReviewUpdateDTO>()); return review is null ? NotFound("Review does not exist.") - : Ok(review); + : Ok(review.Adapt<ReviewDetailModel>()); } [HttpDelete] @@ -82,7 +90,7 @@ namespace Api.Controllers : NotFound("Review does not exist."); } - private static bool UpdateEmpty(ReviewUpdateDTO data) + private static bool UpdateEmpty(ReviewUpdateModel data) { return data.Content is null && data.FoodRating is null && data.ServiceRating is null && data.EnvironmentRating is null diff --git a/Api/Controllers/UserController.cs b/Api/Controllers/UserController.cs index 1a92514b7f515758fe128340d9da526bd2e61628..2a96bc4a7b7bb9d03cf5f735f0c33ea4166f9041 100644 --- a/Api/Controllers/UserController.cs +++ b/Api/Controllers/UserController.cs @@ -1,12 +1,14 @@ -using BusinessLayer.DTOs.User; +using Api.Models.User; +using BusinessLayer.DTOs.User; using BusinessLayer.Services.UserService; using BusinessLayer.Utils.Filters; using BusinessLayer.Utils.Ordering; +using Mapster; using Microsoft.AspNetCore.Mvc; namespace Api.Controllers { - [Route("/[controller]")] + [Route("/api/[controller]")] [ApiController] public class UserController(IUserService userService) : Controller { @@ -17,11 +19,10 @@ namespace Api.Controllers public async Task<IActionResult> GetUserById([FromRoute] Guid userId) { var user = await _userService.GetUserAsync(userId); - if (user == null) - { - return NotFound("User not found."); - } - return Ok(user); + + return user is null + ? NotFound("User not found.") + : Ok(user.Adapt<UserDetailModel>()); } [HttpGet] @@ -38,21 +39,30 @@ namespace Api.Controllers limit, offset, ids); - return Ok(users); + + return Ok(users + .Select(u => u.Adapt<UserModel>()) + .ToList()); } [HttpPost] - public async Task<IActionResult> CreateUser([FromBody] UserCreateDto data) + public async Task<IActionResult> CreateUser([FromBody] UserCreateModel data) { - var user = await _userService.CreateUserAsync(data); - return CreatedAtAction(nameof(CreateUser), user); + var user = await _userService.CreateUserAsync(data.Adapt<UserCreateDto>()); + + return user is null ? + BadRequest() + : CreatedAtAction( + nameof(CreateUser), + new { userId = user.Id }, + user.Adapt<UserDetailModel>()); } [HttpPatch] [Route("{userId:guid}")] public async Task<IActionResult> UpdateUser( [FromRoute] Guid userId, - [FromBody] UserUpdateDto data) + [FromBody] UserUpdateModel data) { if (data.Name is null && data.Email is null) { @@ -69,23 +79,20 @@ namespace Api.Controllers return BadRequest("Email can't be set to empty string."); } - var user = await _userService.UpdateUserAsync(userId, data); - if (user == null) - { - return NotFound("User not found."); - } - return Ok(user); + var user = await _userService.UpdateUserAsync(userId, data.Adapt<UserUpdateDto>()); + + return user is null + ? NotFound("User not found.") + : Ok(user.Adapt<UserDetailModel>()); } [HttpDelete] [Route("{userId:guid}")] public async Task<IActionResult> DeleteUser([FromRoute] Guid userId) { - if (!await _userService.DeleteUserAsync(userId)) - { - return NotFound("User not found."); - } - return Ok(); + return !await _userService.DeleteUserAsync(userId) + ? NotFound("User not found.") + : Ok(); } } } diff --git a/Api/Models/Converter.cs b/Api/Models/Converter.cs deleted file mode 100644 index 6c872f13d3a7d10bb2fd2af0ee857039a72cc2c6..0000000000000000000000000000000000000000 --- a/Api/Models/Converter.cs +++ /dev/null @@ -1,205 +0,0 @@ -using Api.Models.Event; -using Api.Models.EventComment; -using Api.Models.EventParticipant; -using Api.Models.Location; -using Api.Models.Review; -using Api.Models.ReviewAggregate; -using Api.Models.ReviewComment; -using Api.Models.Restaurant; -using Api.Models.User; -using System.Linq.Expressions; -using BusinessLayer.Utils.Filters; - -namespace Api.Models -{ - public static class Converter - { - public static UserModel ToUserModel(DAL.Models.User user) - { - return new UserModel - { - Id = user.Id, - Name = user.Name, - Email = user.Email, - CreatedAt = user.CreatedAt.ToLocalTime(), - UpdatedAt = user.UpdatedAt.ToLocalTime(), - DeletedAt = user.DeletedAt?.ToLocalTime(), - }; - } - - public static UserDetailModel ToUserDetailModel(DAL.Models.User user) - { - return new UserDetailModel - { - Id = user.Id, - Name = user.Name, - Email = user.Email, - CreatedAt = user.CreatedAt.ToLocalTime(), - UpdatedAt = user.UpdatedAt.ToLocalTime(), - DeletedAt = user.DeletedAt?.ToLocalTime(), - MaintainedRestaurants = user.MaintainedRestaurants - .Where(r => r.DeletedAt is null) - .Select(ToRestaurantModel).ToList() - }; - } - - public static ReviewModel ToReviewModel(DAL.Models.Review review) - { - return new ReviewModel - { - Id = review.Id, - Poster = ToUserModel(review.Poster!), - RestaurantId = review.RestaurantId, - Content = review.Content, - FoodRating = review.FoodRating, - ServiceRating = review.ServiceRating, - EnvironmentRating = review.EnvironmentRating, - ServesFreeWater = review.ServesFreeWater, - TimeSpent = review.TimeSpent, - LeftTip = review.LeftTip, - CreatedAt = review.CreatedAt.ToLocalTime(), - UpdatedAt = review.UpdatedAt.ToLocalTime(), - DeletedAt = review.DeletedAt?.ToLocalTime(), - }; - } - - public static ReviewCommentModel ToReviewCommentModel(DAL.Models.ReviewComment comment) - { - return new ReviewCommentModel - { - Id = comment.Id, - Poster = ToUserModel(comment.Poster!), - ReviewId = comment.ReviewId, - ParentCommentId = comment.ParentCommentId, - Content = comment.Content, - CreatedAt = comment.CreatedAt.ToLocalTime(), - UpdatedAt = comment.UpdatedAt.ToLocalTime(), - DeletedAt = comment.DeletedAt?.ToLocalTime(), - }; - } - - public static ReviewAggregateModel ToReviewAggregateModel(DAL.Models.ReviewAggregateResult aggregate) - { - return new ReviewAggregateModel - { - RestaurantId = aggregate.RestaurantId, - FoodRating = aggregate.FoodRating, - EnvironmentRating = aggregate.EnvironmentRating, - ServiceRating = aggregate.ServiceRating, - }; - } - - public static Expression<Func<DAL.Models.User, bool>> ToUserFilterFunc(UserFilter filter) - { - return u => (filter.NameLike == null || u.Name.Contains(filter.NameLike)) - && (filter.EmailLike == null || u.Email.Contains(filter.EmailLike)) - && u.DeletedAt == null; - } - - public static EventModel ToEventModel(DAL.Models.Event eventEntity) - { - return new EventModel - { - Id = eventEntity.Id, - Title = eventEntity.Title, - RestaurantId = eventEntity.RestaurantId, - Date = eventEntity.Date.ToLocalTime(), - Content = eventEntity.Content, - CreatedAt = eventEntity.CreatedAt.ToLocalTime(), - UpdatedAt = eventEntity.UpdatedAt.ToLocalTime(), - DeletedAt = eventEntity.DeletedAt?.ToLocalTime(), - }; - } - - public static EventCommentModel ToEventCommentModel(DAL.Models.EventComment comment) - { - return new EventCommentModel - { - Id = comment.Id, - PosterId = comment.PosterId, - Poster = comment.Poster!.Name, - EventId = comment.EventId, - ParentCommentId = comment.ParentCommentId, - Content = comment.Content, - CreatedAt = comment.CreatedAt.ToLocalTime(), - UpdatedAt = comment.UpdatedAt.ToLocalTime(), - DeletedAt = comment.DeletedAt?.ToLocalTime(), - }; - } - - public static EventParticipantModel ToEventParticipantModel(DAL.Models.EventParticipant participant) - { - return new EventParticipantModel - { - User = ToUserModel(participant.User!), - Event = ToEventModel(participant.Event!), - Attendance = participant.Attendance, - CreatedAt = participant.CreatedAt.ToLocalTime(), - UpdatedAt = participant.UpdatedAt.ToLocalTime(), - DeletedAt = participant.DeletedAt?.ToLocalTime(), - }; - } - - public static RestaurantModel ToRestaurantModel(DAL.Models.Restaurant restaurant) - { - return new RestaurantModel - { - Id = restaurant.Id, - Name = restaurant.Name, - About = restaurant.About, - Phone = restaurant.Phone, - Email = restaurant.Email, - Web = restaurant.Web, - Category = restaurant.Category, - ReviewAggregate = (restaurant.ReviewAggregate is null) - ? null - : ToReviewAggregateModel(restaurant.ReviewAggregate), - CreatedAt = restaurant.CreatedAt.ToLocalTime(), - UpdatedAt = restaurant.UpdatedAt.ToLocalTime(), - DeletedAt = restaurant.DeletedAt?.ToLocalTime(), - }; - } - - public static RestaurantDetailModel ToRestaurantDetailModel(DAL.Models.Restaurant restaurant) - { - return new RestaurantDetailModel - { - Id = restaurant.Id, - Name = restaurant.Name, - About = restaurant.About, - Phone = restaurant.Phone, - Email = restaurant.Email, - Web = restaurant.Web, - Category = restaurant.Category, - Location = ToLocationModel(restaurant.Location!), - ReviewAggregate = (restaurant.ReviewAggregate is null) - ? null - : ToReviewAggregateModel(restaurant.ReviewAggregate), - Maintainers = restaurant.RestaurantMaintainers - .Where(u => u.DeletedAt is null) - .Select(ToUserModel).ToList(), - Events = restaurant.Events - .Where(e => e.DeletedAt is null) - .Select(ToEventModel).ToList(), - CreatedAt = restaurant.CreatedAt.ToLocalTime(), - UpdatedAt = restaurant.UpdatedAt.ToLocalTime(), - DeletedAt = restaurant.DeletedAt?.ToLocalTime() - }; - } - - public static LocationModel ToLocationModel(DAL.Models.Location location) - { - return new LocationModel - { - RestaurantId = location.RestaurantId, - Country = location.Country, - City = location.City, - Address = location.Address, - ZipCode = location.Zipcode, - CreatedAt = location.CreatedAt, - UpdatedAt = location.UpdatedAt, - DeletedAt = location.DeletedAt - }; - } - } -} diff --git a/Api/Models/Event/EventInfoModel.cs b/Api/Models/Event/EventInfoModel.cs new file mode 100644 index 0000000000000000000000000000000000000000..83fa124b062d8b6f2fce327b19070d20643333cb --- /dev/null +++ b/Api/Models/Event/EventInfoModel.cs @@ -0,0 +1,11 @@ +using Api.Models.Restaurant; + +namespace Api.Models.Event +{ + public class EventInfoModel + { + public required string Title { get; set; } + public DateTime Date { get; set; } + public required RestaurantModel Restaurant { get; set; } + } +} diff --git a/Api/Models/EventComment/EventCommentModel.cs b/Api/Models/EventComment/EventCommentModel.cs index 32d90f745654469826fc014fdcd45c6d444a5751..5ad3971dada0ebd7dfca3c5a319297c264840291 100644 --- a/Api/Models/EventComment/EventCommentModel.cs +++ b/Api/Models/EventComment/EventCommentModel.cs @@ -1,13 +1,17 @@ -namespace Api.Models.EventComment +using Api.Models.Event; +using Api.Models.User; + +namespace Api.Models.EventComment { public class EventCommentModel { public Guid Id { get; set; } - public Guid PosterId { get; set; } - public required string Poster { get; set; } + public UserModel? Poster { get; set; } public Guid EventId { get; set; } - public required string Content { get; set; } + public EventModel? Event { get; set; } public Guid? ParentCommentId { get; set; } + public List<EventCommentModel> ChildComments { get; set; } = new List<EventCommentModel>(); + public required string Content { get; set; } public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } public DateTime? DeletedAt { get; set; } diff --git a/Api/Models/Restaurant/RestaurantDetailModel.cs b/Api/Models/Restaurant/RestaurantDetailModel.cs index 5937294014fe6663b5316a6782ecb7858aa71b07..c8d1b4806d58a7e42355a7d79221401a0f75671e 100644 --- a/Api/Models/Restaurant/RestaurantDetailModel.cs +++ b/Api/Models/Restaurant/RestaurantDetailModel.cs @@ -16,8 +16,7 @@ namespace Api.Models.Restaurant public required string Category { get; set; } public required LocationModel Location { get; set; } public ReviewAggregateModel? ReviewAggregate { get; set; } - public required List<UserModel> Maintainers { get; set; } - public required List<EventModel> Events { get; set; } + public required List<UserModel> RestaurantMaintainers { get; set; } public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } public DateTime? DeletedAt { get; set; } diff --git a/Api/Models/Restaurant/RestaurantModel.cs b/Api/Models/Restaurant/RestaurantModel.cs index f03671f9fca451a5ff085d78b8d6b249e73d009f..9a3647b11ca3ae4be5a1861f50f355c5a75750bf 100644 --- a/Api/Models/Restaurant/RestaurantModel.cs +++ b/Api/Models/Restaurant/RestaurantModel.cs @@ -1,3 +1,4 @@ +using Api.Models.Location; using Api.Models.Review; using Api.Models.ReviewAggregate; using Api.Models.User; @@ -8,11 +9,8 @@ public class RestaurantModel { public Guid Id { get; set; } public required string Name { get; set; } - public string? About { get; set; } - public string? Phone { get; set; } - public string? Email { get; set; } - public string? Web { get; set; } public string? Category { get; set; } + public required LocationModel Location { get; set; } public ReviewAggregateModel? ReviewAggregate { get; set; } public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } diff --git a/Api/Models/Review/ReviewDetailModel.cs b/Api/Models/Review/ReviewDetailModel.cs new file mode 100644 index 0000000000000000000000000000000000000000..68c5d60bc39482cb567b0b8b153fe0b1df448ffc --- /dev/null +++ b/Api/Models/Review/ReviewDetailModel.cs @@ -0,0 +1,22 @@ +using Api.Models.Restaurant; +using Api.Models.User; + +namespace Api.Models.Review +{ + public class ReviewDetailModel + { + public Guid Id { get; set; } + public UserModel? Poster { get; set; } + public RestaurantModel? Restaurant { get; set; } + public required string Content { get; set; } + public uint FoodRating { get; set; } + public uint ServiceRating { get; set; } + public uint EnvironmentRating { get; set; } + public bool? ServesFreeWater { get; set; } + public float? TimeSpent { get; set; } + public bool? LeftTip { get; set; } + public DateTime CreatedAt { get; set; } + public DateTime UpdatedAt { get; set; } + public DateTime? DeletedAt { get; set; } + } +} diff --git a/Api/Models/Review/ReviewModel.cs b/Api/Models/Review/ReviewModel.cs index 6b8c6af0162b9770146e2a80845f3c21285577c3..4ab001f17eaccdf1a84f4000e102938cfa339917 100644 --- a/Api/Models/Review/ReviewModel.cs +++ b/Api/Models/Review/ReviewModel.cs @@ -1,4 +1,5 @@ using Api.Models.User; +using BusinessLayer.DTOs.User; namespace Api.Models.Review { @@ -6,14 +7,9 @@ namespace Api.Models.Review { public Guid Id { get; set; } public UserModel? Poster { get; set; } - public Guid RestaurantId { get; set; } - public required string Content { get; set; } public uint FoodRating { get; set; } public uint ServiceRating { get; set; } public uint EnvironmentRating { get; set; } - public bool? ServesFreeWater { get; set; } - public float? TimeSpent { get; set; } - public bool? LeftTip { get; set; } public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } public DateTime? DeletedAt { get; set; } diff --git a/Api/Models/User/UserModel.cs b/Api/Models/User/UserModel.cs index 593f8a518026afc0410531c3a4959f28c39d8a92..6fade8b3bac6825fcb25084156dc1df2edc87618 100644 --- a/Api/Models/User/UserModel.cs +++ b/Api/Models/User/UserModel.cs @@ -4,7 +4,6 @@ { public Guid Id { get; set; } public required string Name { get; set; } - public required string Email { get; set; } public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } public DateTime? DeletedAt { get; set; } diff --git a/BusinessLayer/DTOs/Event/EventCreateDTO.cs b/BusinessLayer/DTOs/Event/EventCreateDTO.cs index 5081225035b8d7e2898871c525993f2d69311420..4c0c7d990b74fadfcaa533f161e6fb33c160cd21 100644 --- a/BusinessLayer/DTOs/Event/EventCreateDTO.cs +++ b/BusinessLayer/DTOs/Event/EventCreateDTO.cs @@ -2,7 +2,7 @@ namespace BusinessLayer.DTOs.Event { - public class EventCreateDTO + public record EventCreateDTO { [Required] public Guid CreatorId { get; set; } diff --git a/BusinessLayer/DTOs/Event/EventDTO.cs b/BusinessLayer/DTOs/Event/EventDTO.cs index 24379c5bc99875041b9197afd1ace0a96a0d1d37..ebcce05080f17203a348e6fd5eb55ec3a2c328e5 100644 --- a/BusinessLayer/DTOs/Event/EventDTO.cs +++ b/BusinessLayer/DTOs/Event/EventDTO.cs @@ -2,7 +2,7 @@ namespace BusinessLayer.DTOs.Event { - public class EventDTO + public record EventDTO { public Guid Id { get; set; } public required string Title { get; set; } diff --git a/BusinessLayer/DTOs/Event/EventInfoDTO.cs b/BusinessLayer/DTOs/Event/EventInfoDTO.cs index 9fbc7b3152ddbe5a9a2c096379743c26361dbae5..77e2276402d55da698676add681e798c6da99933 100644 --- a/BusinessLayer/DTOs/Event/EventInfoDTO.cs +++ b/BusinessLayer/DTOs/Event/EventInfoDTO.cs @@ -2,7 +2,7 @@ namespace BusinessLayer.DTOs.Event { - public class EventInfoDTO + public record EventInfoDTO { public required string Title { get; set; } public DateTime Date { get; set; } diff --git a/BusinessLayer/DTOs/Event/EventUpdateDTO.cs b/BusinessLayer/DTOs/Event/EventUpdateDTO.cs index b86129bb69473dce84504fba17de460b6449f259..18f93a7e28448a3ab4a46280d32f9626ce301707 100644 --- a/BusinessLayer/DTOs/Event/EventUpdateDTO.cs +++ b/BusinessLayer/DTOs/Event/EventUpdateDTO.cs @@ -2,7 +2,7 @@ namespace BusinessLayer.DTOs.Event { - public class EventUpdateDTO + public record EventUpdateDTO { [MaxLength(200)] public string? Title { get; set; } diff --git a/BusinessLayer/DTOs/EventComment/EventCommentCreateDTO.cs b/BusinessLayer/DTOs/EventComment/EventCommentCreateDTO.cs index e786c3ea0af7906ad58118078382e0487b5178f0..7ecbcb3095a0a347d59d01ba740971373dda0817 100644 --- a/BusinessLayer/DTOs/EventComment/EventCommentCreateDTO.cs +++ b/BusinessLayer/DTOs/EventComment/EventCommentCreateDTO.cs @@ -2,7 +2,7 @@ namespace BusinessLayer.DTOs.EventComment { - public class EventCommentCreateDTO + public record EventCommentCreateDTO { [Required] public Guid PosterId { get; set; } diff --git a/BusinessLayer/DTOs/EventComment/EventCommentDTO.cs b/BusinessLayer/DTOs/EventComment/EventCommentDTO.cs index be0bd245b0a86ef5fe6e2fa0adb8d0b134bc4b21..42725642e517297305371c0a81faa0be17ad37df 100644 --- a/BusinessLayer/DTOs/EventComment/EventCommentDTO.cs +++ b/BusinessLayer/DTOs/EventComment/EventCommentDTO.cs @@ -3,7 +3,7 @@ using BusinessLayer.DTOs.User; namespace BusinessLayer.DTOs.EventComment { - public class EventCommentDTO + public record EventCommentDTO { public Guid Id { get; set; } public UserDto? Poster { get; set; } diff --git a/BusinessLayer/DTOs/EventComment/EventCommentUpdateDTO.cs b/BusinessLayer/DTOs/EventComment/EventCommentUpdateDTO.cs index 6754d9d781013ffb7506118437f382d6534a31c0..eb7e2aca91613ef32c8c9bd2e1f7471f94509296 100644 --- a/BusinessLayer/DTOs/EventComment/EventCommentUpdateDTO.cs +++ b/BusinessLayer/DTOs/EventComment/EventCommentUpdateDTO.cs @@ -2,7 +2,7 @@ namespace BusinessLayer.DTOs.EventComment { - public class EventCommentUpdateDTO + public record EventCommentUpdateDTO { [Required] [MaxLength(1800)] diff --git a/BusinessLayer/DTOs/EventParticipant/EventParticipantCreateDTO.cs b/BusinessLayer/DTOs/EventParticipant/EventParticipantCreateDTO.cs index 3b176a868a27477e8726e63be27140cc16954e3c..11dd75c68ec2b34dd587287bec86dc84aa03adc3 100644 --- a/BusinessLayer/DTOs/EventParticipant/EventParticipantCreateDTO.cs +++ b/BusinessLayer/DTOs/EventParticipant/EventParticipantCreateDTO.cs @@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations; namespace BusinessLayer.DTOs.EventParticipant { - public class EventParticipantCreateDTO + public record EventParticipantCreateDTO { [Required] public Guid UserId { get; set; } diff --git a/BusinessLayer/DTOs/EventParticipant/EventParticipantDTO.cs b/BusinessLayer/DTOs/EventParticipant/EventParticipantDTO.cs index 597327dfffb4585266fd477b7b833dbb01bdf6dd..982dbc48680c2b3d72ad0151442e6576fffb3dd6 100644 --- a/BusinessLayer/DTOs/EventParticipant/EventParticipantDTO.cs +++ b/BusinessLayer/DTOs/EventParticipant/EventParticipantDTO.cs @@ -4,7 +4,7 @@ using DAL.Enums; namespace BusinessLayer.DTOs.EventParticipant { - public class EventParticipantDTO + public record EventParticipantDTO { public Guid Id { get; set; } public required UserDto User { get; set; } diff --git a/BusinessLayer/DTOs/EventParticipant/EventParticipantUpdateDTO.cs b/BusinessLayer/DTOs/EventParticipant/EventParticipantUpdateDTO.cs index 69f2298bf292388c8cc4e7095ed24e7b1f4e64b7..5dec8f9004f1c0ff1a468a07370f60df2dac1957 100644 --- a/BusinessLayer/DTOs/EventParticipant/EventParticipantUpdateDTO.cs +++ b/BusinessLayer/DTOs/EventParticipant/EventParticipantUpdateDTO.cs @@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations; namespace BusinessLayer.DTOs.EventParticipant { - public class EventParticipantUpdateDTO + public record EventParticipantUpdateDTO { [Required] public ParticipantType Attendance { get; set; } diff --git a/BusinessLayer/DTOs/Review/ReviewDTO.cs b/BusinessLayer/DTOs/Review/ReviewDTO.cs index 9385f536917048b7374de4d99ed3d0d1417dee4c..17eb0319691b58cce4d388ed1e25d251908b1392 100644 --- a/BusinessLayer/DTOs/Review/ReviewDTO.cs +++ b/BusinessLayer/DTOs/Review/ReviewDTO.cs @@ -1,5 +1,4 @@ -using BusinessLayer.DTOs.Restaurant; -using BusinessLayer.DTOs.User; +using BusinessLayer.DTOs.User; namespace BusinessLayer.DTOs.Review { diff --git a/BusinessLayer/DTOs/Review/ReviewDetailDTO.cs b/BusinessLayer/DTOs/Review/ReviewDetailDTO.cs index 38d59cf2b2e5d2b171faec3b2392f1b52b17d5e3..dc8eafeb4658df9f4ca9ee0d03cd09a10b56f380 100644 --- a/BusinessLayer/DTOs/Review/ReviewDetailDTO.cs +++ b/BusinessLayer/DTOs/Review/ReviewDetailDTO.cs @@ -3,7 +3,7 @@ using BusinessLayer.DTOs.User; namespace BusinessLayer.DTOs.Review { - public class ReviewDetailDTO + public record ReviewDetailDTO { public Guid Id { get; set; } public UserDto? Poster { get; set; } diff --git a/BusinessLayer/DTOs/ReviewAggregate/ReviewAggregateDTO.cs b/BusinessLayer/DTOs/ReviewAggregate/ReviewAggregateDTO.cs index b6261b592df8a526137802697664df3e857dcad6..d3ebd049163e446d1dd8e23b2004b9ea981fbb66 100644 --- a/BusinessLayer/DTOs/ReviewAggregate/ReviewAggregateDTO.cs +++ b/BusinessLayer/DTOs/ReviewAggregate/ReviewAggregateDTO.cs @@ -1,6 +1,6 @@ namespace BusinessLayer.DTOs.ReviewAggregate { - public class ReviewAggregateDTO + public record ReviewAggregateDTO { public Guid RestaurantId { get; set; } public uint FoodRating { get; set; } diff --git a/BusinessLayer/DTOs/ReviewComment/ReviewCommentCreateDTO.cs b/BusinessLayer/DTOs/ReviewComment/ReviewCommentCreateDTO.cs index 30fb0148e31fdc2214702d7dcf435fbd77f46b5e..766c7b7b4208027bce172ccea3d4925ee9537b85 100644 --- a/BusinessLayer/DTOs/ReviewComment/ReviewCommentCreateDTO.cs +++ b/BusinessLayer/DTOs/ReviewComment/ReviewCommentCreateDTO.cs @@ -2,7 +2,7 @@ namespace BusinessLayer.DTOs.ReviewComment { - public class ReviewCommentCreateDTO + public record ReviewCommentCreateDTO { [Required] public Guid PosterId { get; set; } diff --git a/BusinessLayer/DTOs/ReviewComment/ReviewCommentDTO.cs b/BusinessLayer/DTOs/ReviewComment/ReviewCommentDTO.cs index f04db4bf0dfbc72656f4f4e52ee0622629e14240..3640089e82d6ca0aa15bd034e42ace44dc04d29f 100644 --- a/BusinessLayer/DTOs/ReviewComment/ReviewCommentDTO.cs +++ b/BusinessLayer/DTOs/ReviewComment/ReviewCommentDTO.cs @@ -3,7 +3,7 @@ using BusinessLayer.DTOs.User; namespace BusinessLayer.DTOs.ReviewComment { - public class ReviewCommentDTO + public record ReviewCommentDTO { public Guid Id { get; set; } public UserDto? Poster { get; set; } diff --git a/BusinessLayer/DTOs/ReviewComment/ReviewCommentUpdateDTO.cs b/BusinessLayer/DTOs/ReviewComment/ReviewCommentUpdateDTO.cs index 6af02e9f53138bdec063ced429fcd9b816c8b4fa..03c872b69c96d178aae28e839ccbd01639cfec08 100644 --- a/BusinessLayer/DTOs/ReviewComment/ReviewCommentUpdateDTO.cs +++ b/BusinessLayer/DTOs/ReviewComment/ReviewCommentUpdateDTO.cs @@ -2,7 +2,7 @@ namespace BusinessLayer.DTOs.ReviewComment { - public class ReviewCommentUpdateDTO + public record ReviewCommentUpdateDTO { [Required] [MaxLength(1800)] diff --git a/BusinessLayer/DTOs/User/UserDetailDto.cs b/BusinessLayer/DTOs/User/UserDetailDto.cs index d3781b1d668c0a7dd07ad1b39de1fcc94d7f2376..f5b469394dce9be41a6a24ec275fd8ede799d65b 100644 --- a/BusinessLayer/DTOs/User/UserDetailDto.cs +++ b/BusinessLayer/DTOs/User/UserDetailDto.cs @@ -2,7 +2,7 @@ using BusinessLayer.DTOs.Restaurant; namespace BusinessLayer.DTOs.User { - public class UserDetailDto + public record UserDetailDto { public Guid Id { get; set; } public required string Name { get; set; } diff --git a/BusinessLayer/Services/EventCommentService/EventCommentService.cs b/BusinessLayer/Services/EventCommentService/EventCommentService.cs index 942bbfebd94bf42b9fbb07af443c05427aa7c47a..4cce676edc4e3dc5c847f0c568f629f3c48aea14 100644 --- a/BusinessLayer/Services/EventCommentService/EventCommentService.cs +++ b/BusinessLayer/Services/EventCommentService/EventCommentService.cs @@ -77,8 +77,8 @@ namespace BusinessLayer.Services.EventCommentService var result = await query.SingleOrDefaultAsync(c => c.Id == id && c.DeletedAt == null); if (result == null - || (includeUser && result.Poster.DeletedAt != null) - || (includeEvent && result.Event.DeletedAt != null)) + || (includeUser && result.Poster!.DeletedAt != null) + || (includeEvent && result.Event!.DeletedAt != null)) { return null; } diff --git a/BusinessLayer/Utils/Ordering/OrderingManager.cs b/BusinessLayer/Utils/Ordering/OrderingManager.cs index 195d8c5a1b5c881284139592b5645b1d1f426bb8..4c422961c13721d6bd62265abeab993f89ff1387 100644 --- a/BusinessLayer/Utils/Ordering/OrderingManager.cs +++ b/BusinessLayer/Utils/Ordering/OrderingManager.cs @@ -70,8 +70,8 @@ namespace BusinessLayer.Utils.Ordering { EventOrdering.DateAscending => query.OrderBy(e => e.Date), EventOrdering.DateDescending => query.OrderByDescending(e => e.Date), - EventOrdering.RestaurantNameAscending => query.OrderBy(e => e.Restaurant.Name), - EventOrdering.RestaurantNameDescending => query.OrderByDescending(e => e.Restaurant.Name), + EventOrdering.RestaurantNameAscending => query.OrderBy(e => e.Restaurant!.Name), + EventOrdering.RestaurantNameDescending => query.OrderByDescending(e => e.Restaurant!.Name), _ => query.OrderBy(e => e.Date) }; }