✨ Able to list awards
This commit is contained in:
		@@ -589,6 +589,25 @@ public class PostController(
 | 
				
			|||||||
        [MaxLength(4096)] public string? Message { get; set; }
 | 
					        [MaxLength(4096)] public string? Message { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    [HttpGet("{id:guid}/awards")]
 | 
				
			||||||
 | 
					    public async Task<ActionResult<PostAward>> GetPostAwards(Guid id, [FromQuery] int offset = 0,
 | 
				
			||||||
 | 
					        [FromQuery] int take = 20)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        var queryable = db.PostAwards
 | 
				
			||||||
 | 
					            .Where(a => a.PostId == id)
 | 
				
			||||||
 | 
					            .AsQueryable();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        var totalCount = await queryable.CountAsync();
 | 
				
			||||||
 | 
					        Response.Headers.Append("X-Total", totalCount.ToString());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        var awards = await queryable
 | 
				
			||||||
 | 
					            .Take(take)
 | 
				
			||||||
 | 
					            .Skip(offset)
 | 
				
			||||||
 | 
					            .ToListAsync();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return Ok(awards);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public class PostAwardResponse
 | 
					    public class PostAwardResponse
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public Guid OrderId { get; set; }
 | 
					        public Guid OrderId { get; set; }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user