Skip to content

Commit

Permalink
Merge pull request #17 from bertusviljoen/feature/bertus_logging
Browse files Browse the repository at this point in the history
refactor(todos): remove obsolete Todo command and handler files
  • Loading branch information
bertusviljoen authored Dec 10, 2024
2 parents 941369f + 0458281 commit aec4b2b
Show file tree
Hide file tree
Showing 28 changed files with 62 additions and 360 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Domain.Elevators;
using MediatR;
using Microsoft.Extensions.Logging;

namespace Application.Elevators.Request;

internal sealed class ElevatorUpdatedDomainEventHandler(ILogger<ElevatorUpdatedDomainEventHandler> logger) : INotificationHandler<ElevatorUpdatedDomainEvent>
{
public Task Handle(ElevatorUpdatedDomainEvent notification, CancellationToken cancellationToken)
{
logger.LogInformation("Elevator updated with the following state: {@Elevator}", notification.Elevator);
return Task.CompletedTask;
}
}
1 change: 1 addition & 0 deletions src/Application/Services/InMemoryElevatorPoolService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public async Task<Result> UpdateElevatorAsync(ElevatorItem elevator, Cancellatio
dbElevator.DoorStatus = elevator.DoorStatus;
dbElevator.DestinationFloor = elevator.DestinationFloor;
dbElevator.DestinationFloors = elevator.DestinationFloors.Count > 0 ? string.Join(",", elevator.DestinationFloors.ToList()) : "";
dbElevator.DomainEvents.Add(new ElevatorUpdatedDomainEvent(dbElevator));
await context.SaveChangesAsync(cancellationToken);
}

Expand Down
5 changes: 0 additions & 5 deletions src/Application/Todos/Complete/CompleteTodoCommand.cs

This file was deleted.

40 changes: 0 additions & 40 deletions src/Application/Todos/Complete/CompleteTodoCommandHandler.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/Application/Todos/Complete/CompleteTodoCommandValidator.cs

This file was deleted.

13 changes: 0 additions & 13 deletions src/Application/Todos/Create/CreateTodoCommand.cs

This file was deleted.

52 changes: 0 additions & 52 deletions src/Application/Todos/Create/CreateTodoCommandHandler.cs

This file was deleted.

14 changes: 0 additions & 14 deletions src/Application/Todos/Create/CreateTodoCommandValidator.cs

This file was deleted.

5 changes: 0 additions & 5 deletions src/Application/Todos/Delete/DeleteTodoCommand.cs

This file was deleted.

31 changes: 0 additions & 31 deletions src/Application/Todos/Delete/DeleteTodoCommandHandler.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/Application/Todos/Delete/DeleteTodoCommandValidator.cs

This file was deleted.

5 changes: 0 additions & 5 deletions src/Application/Todos/Get/GetTodosQuery.cs

This file was deleted.

37 changes: 0 additions & 37 deletions src/Application/Todos/Get/GetTodosQueryHandler.cs

This file was deleted.

13 changes: 0 additions & 13 deletions src/Application/Todos/Get/TodoResponse.cs

This file was deleted.

5 changes: 0 additions & 5 deletions src/Application/Todos/GetById/GetTodoByIdQuery.cs

This file was deleted.

38 changes: 0 additions & 38 deletions src/Application/Todos/GetById/GetTodoByIdQueryHandler.cs

This file was deleted.

13 changes: 0 additions & 13 deletions src/Application/Todos/GetById/TodoResponse.cs

This file was deleted.

8 changes: 8 additions & 0 deletions src/Domain/Elevators/Elevator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,12 @@ public class Elevator : AuditableEntity
public required Guid BuildingId { get; set; }
/// <summary> Get or set the building the elevator is in. </summary>
public virtual Building Building { get; set; }

/// <summary> Override the ToString method to provide a single line string representation of the elevator. </summary>
/// <returns></returns>
public override string ToString()
{
//Single line with all the property values
return $"Elevator {Number} is on floor {CurrentFloor} and is moving to {DestinationFloor} with status {ElevatorStatus}";
}
}
8 changes: 8 additions & 0 deletions src/Domain/Elevators/ElevatorUpdatedDomainEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Domain.Common;

namespace Domain.Elevators;

/// <summary> Domain event for when an elevator is updated. </summary>
public record ElevatorUpdatedDomainEvent(Elevator Elevator) : IDomainEvent;


10 changes: 0 additions & 10 deletions src/Domain/Todos/Priority.cs

This file was deleted.

16 changes: 0 additions & 16 deletions src/Domain/Todos/TodoItem.cs

This file was deleted.

5 changes: 0 additions & 5 deletions src/Domain/Todos/TodoItemCompletedDomainEvent.cs

This file was deleted.

5 changes: 0 additions & 5 deletions src/Domain/Todos/TodoItemCreatedDomainEvent.cs

This file was deleted.

5 changes: 0 additions & 5 deletions src/Domain/Todos/TodoItemDeletedDomainEvent.cs

This file was deleted.

Loading

0 comments on commit aec4b2b

Please sign in to comment.