Skip to content

Commit

Permalink
Order notes by date
Browse files Browse the repository at this point in the history
  • Loading branch information
PaddiM8 committed Nov 12, 2023
1 parent a46203a commit 7871a05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions api/Services/NoteService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ public async Task<ErrorOr<List<NoteDto>>> GetAllAsync(string userId, string proj
if (project == null)
return ProjectService.ProjectNotFoundError<List<NoteDto>>();

return await _dataContext.Notes
return _dataContext.Notes
.Where(x => x.ProjectId == projectId && x.TicketId == ticketId)
.OrderBy(x => x.Timestamp)
.ProjectTo<NoteDto>(_mapper.ConfigurationProvider)
.ToListAsync();
.ToList();
}

public async Task<ErrorOr<NoteDto>> AddAsync(string userId, string projectId, int ticketId, string content)
Expand Down Expand Up @@ -110,4 +111,4 @@ public async Task<ErrorOr<Updated>> EditAsync(

return new ErrorOr<Updated>();
}
}
}
4 changes: 2 additions & 2 deletions api/Services/TicketService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public async Task<ErrorOr<TicketDto>> GetAsync(
.Where(x => x.Id == ticketId && x.ProjectId == project.Id)
.Include(x => x.Project)
.Include(x => x.Assignees)
.Include(x => x.Notes)
.Include(x => x.Notes.OrderBy(note => note.Timestamp))
.SingleOrDefaultAsync();

return ticket == null
Expand Down Expand Up @@ -433,4 +433,4 @@ private async Task<string> SaveImagesAndReplaceUrls(string projectId, string tic
}
);
}
}
}

0 comments on commit 7871a05

Please sign in to comment.