Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions TickAPI/TickAPI.Tests/Events/Services/EventServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,8 @@ public async Task GetEventDetailsAsync_WhenSuccessful_ShouldReturnEventDetails()
var ticketServiceMock = new Mock<ITicketService>();

eventRepositoryMock
.Setup(m => m.GetEventById(@event.Id))
.Returns(Result<Event>.Success(@event));
.Setup(m => m.GetEventByIdAsync(@event.Id))
.ReturnsAsync(Result<Event>.Success(@event));

ticketServiceMock
.Setup(m => m.GetNumberOfAvailableTicketsByType(It.IsAny<TicketType>()))
Expand Down Expand Up @@ -669,8 +669,8 @@ public async Task GetEventDetailsAsync_WhenFails_ShouldReturnEventError()
var ticketServiceMock = new Mock<ITicketService>();

eventRepositoryMock
.Setup(m => m.GetEventById(@event.Id))
.Returns(Result<Event>.Failure(StatusCodes.Status404NotFound, $"event with id {@event.Id} not found"));
.Setup(m => m.GetEventByIdAsync(@event.Id))
.ReturnsAsync(Result<Event>.Failure(StatusCodes.Status404NotFound, $"event with id {@event.Id} not found"));

var sut = new EventService(eventRepositoryMock.Object, organizerServiceMock.Object, addressServiceMock.Object,
dateTimeServiceMock.Object, paginationServiceMock.Object, categoryServiceMock.Object, ticketServiceMock.Object);
Expand Down
2 changes: 1 addition & 1 deletion TickAPI/TickAPI/Events/Abstractions/IEventRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public interface IEventRepository
public Task AddNewEventAsync(Event @event);
public IQueryable<Event> GetEvents();
public IQueryable<Event> GetEventsByOranizer(Organizer organizer);
public Result<Event> GetEventById(Guid eventId);
public Task<Result<Event>> GetEventByIdAsync(Guid eventId);
}
22 changes: 17 additions & 5 deletions TickAPI/TickAPI/Events/Repositories/EventRepository.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using TickAPI.Common.Results.Generic;
using Microsoft.EntityFrameworkCore;
using TickAPI.Common.Results.Generic;
using TickAPI.Common.TickApiDbContext;
using TickAPI.Events.Abstractions;
using TickAPI.Events.Models;
Expand All @@ -23,17 +24,28 @@ public async Task AddNewEventAsync(Event @event)

public IQueryable<Event> GetEvents()
{
return _tickApiDbContext.Events;
return _tickApiDbContext.Events
.Include(e => e.Address)
.Include(e => e.TicketTypes)
.Include(e => e.Categories);
}

public IQueryable<Event> GetEventsByOranizer(Organizer organizer)
{
return _tickApiDbContext.Events.Where(e => e.Organizer.Id == organizer.Id);
return _tickApiDbContext.Events
.Include(e => e.Address)
.Include(e => e.TicketTypes)
.Include(e => e.Categories)
.Where(e => e.Organizer.Id == organizer.Id);
}

public Result<Event> GetEventById(Guid eventId)
public async Task<Result<Event>> GetEventByIdAsync(Guid eventId)
{
var @event = _tickApiDbContext.Events.Find(eventId);
var @event = await _tickApiDbContext.Events
.Include(e => e.Address)
.Include(e => e.TicketTypes)
.Include(e => e.Categories)
.FirstOrDefaultAsync(e => e.Id == eventId);

if (@event == null)
{
Expand Down
2 changes: 1 addition & 1 deletion TickAPI/TickAPI/Events/Services/EventService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public async Task<Result<PaginationDetails>> GetEventsPaginationDetailsAsync(int

public async Task<Result<GetEventDetailsResponseDto>> GetEventDetailsAsync(Guid eventId)
{
var eventResult = _eventRepository.GetEventById(eventId);
var eventResult = await _eventRepository.GetEventByIdAsync(eventId);

if (eventResult.IsError)
{
Expand Down
Loading