Skip to content

Commit

Permalink
Merge pull request #33 from ApplETS/ftr/report-email
Browse files Browse the repository at this point in the history
[PS-145] Ftr/report email
  • Loading branch information
HugoMigner authored Apr 2, 2024
2 parents 7bd0675 + aa9fe42 commit 3081f80
Show file tree
Hide file tree
Showing 19 changed files with 1,189 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/Controllers/EventsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public IActionResult ReportEvent(Guid id, [FromBody] CreateReportRequestDTO requ
{
logger.LogInformation($"Reporting event {id}");

reportService.ReportEvent(id, request);
reportService.ReportEventAsync(id, request);

return Ok();
}
Expand Down
2 changes: 1 addition & 1 deletion core/Controllers/ModeratorEventsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public IActionResult UpdateEventState(Guid id, [FromQuery] State newState, [From
}

[HttpGet]
public ActionResult<IEnumerable<EventResponseDTO>> GetEventsModerator(
public ActionResult<IEnumerable<EventModeratorResponseDTO>> GetEventsModerator(
[FromQuery] DateTime? startDate,
[FromQuery] DateTime? endDate,
[FromQuery] IEnumerable<string>? activityAreas,
Expand Down
4 changes: 4 additions & 0 deletions core/Data/Entities/Publication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public partial class Publication

public DateTime? PublicationDate { get; set; }

public int ReportCount { get; set; } = 0;

public bool HasBeenReported { get; set; } = false;

public Guid? ModeratorId { get; set; }

public Guid OrganizerId { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions core/Data/Requests/EventRequestDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public class EventRequestDTO

public string Content { get; set; } = null!;

public int ReportCount { get; set; }

public DateTime PublicationDate { get; set; }

public DateTime EventStartDate { get; set; }
Expand Down
30 changes: 29 additions & 1 deletion core/Data/Responses/EventResponseDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static EventResponseDTO Map(Event oneEvent)
Title = oneEvent.Publication.Title,
Content = oneEvent.Publication.Content,
ImageUrl = oneEvent.Publication.ImageUrl,
ImageAltText = oneEvent.Publication.ImageAltText,
ImageAltText = oneEvent.Publication.ImageAltText!,
Tags = oneEvent.Publication.Tags.Select(TagResponseDTO.Map),
State = oneEvent.Publication.State,
Reason = oneEvent.Publication.Reason,
Expand All @@ -59,3 +59,31 @@ public static EventResponseDTO Map(Event oneEvent)
};
}
}

public class EventModeratorResponseDTO : EventResponseDTO
{
public int ReportCount { get; set; } = 0;

public static new EventModeratorResponseDTO Map(Event oneEvent)
{
return new EventModeratorResponseDTO
{
Id = oneEvent.Id,
Title = oneEvent.Publication.Title,
Content = oneEvent.Publication.Content,
ImageUrl = oneEvent.Publication.ImageUrl,
ImageAltText = oneEvent.Publication.ImageAltText!,
Tags = oneEvent.Publication.Tags.Select(TagResponseDTO.Map),
State = oneEvent.Publication.State,
Reason = oneEvent.Publication.Reason,
PublicationDate = oneEvent.Publication.PublicationDate,
EventStartDate = oneEvent.EventStartDate,
EventEndDate = oneEvent.EventEndDate,
ReportCount = oneEvent.Publication.ReportCount,
CreatedAt = oneEvent.Publication.CreatedAt,
UpdatedAt = oneEvent.Publication.UpdatedAt,
Moderator = oneEvent.Publication.Moderator != null ? UserResponseDTO.Map(oneEvent.Publication.Moderator!) : null,
Organizer = UserResponseDTO.Map(oneEvent.Publication.Organizer),
};
}
}
2 changes: 1 addition & 1 deletion core/Data/Responses/ReportResponseDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static ReportResponseDTO Map(Report report)
Title = report.Publication.Title,
Content = report.Publication.Content,
ImageUrl = report.Publication.ImageUrl,
ImageAltText = report.Publication.ImageAltText,
ImageAltText = report.Publication.ImageAltText!,
Tags = report.Publication.Tags.Select(TagResponseDTO.Map),
State = report.Publication.State,
PublicationDate = report.Publication.PublicationDate,
Expand Down
Loading

0 comments on commit 3081f80

Please sign in to comment.