added more control to request listing

This commit is contained in:
Damien Ostler 2024-02-22 23:02:56 -05:00
parent eb12979506
commit 6908225f21
4 changed files with 40 additions and 12 deletions

View File

@ -35,7 +35,7 @@ public class RequestsController : Controller
}
[Route("PaymentWebhook")]
[HttpPost]
[HttpPost ]
[AllowAnonymous]
public async Task<IActionResult> ProcessWebhookEvent()
{
@ -660,21 +660,49 @@ public class RequestsController : Controller
}
return Ok();
}
[Authorize("read:request")]
[HttpGet]
[Route("Customer/Requests")]
public async Task<IActionResult> GetRequests(string search="",int offset = 0, int pageSize = 10)
public async Task<IActionResult> GetRequests([FromQuery]bool completed = true, [FromQuery]bool declined = true, [FromQuery]bool accepted = true, [FromQuery]bool paid = true,
string search = "", int offset = 0, int pageSize = 10)
{
var userId = User.GetUserId();
var requests = await _dbContext.Requests
.Where(x=>x.UserId==userId)
.Include(x=>x.Artist)
.Where(x=>x.Artist.Name.Contains(search) || x.Message.Contains(search))
.Skip(offset).Take(pageSize).ToListAsync();
var result = requests.Select(x=>x.ToModel()).ToList();
var query = _dbContext.Requests
.Where(x => x.UserId == userId);
if (completed)
{
query = query.Where(x => x.Completed );
}
if (declined)
{
query = query.Where(x => x.Declined);
}
if (accepted)
{
query = query.Where(x => x.Accepted);
}
if (paid)
{
query = query.Where(x => x.Paid);
}
if (!string.IsNullOrWhiteSpace(search))
{
query = query.Where(x => x.Artist.Name.Contains(search) || x.Message.Contains(search));
}
var requests = await query
.Include(x => x.Artist)
.Skip(offset)
.Take(pageSize)
.ToListAsync();
var result = requests.Select(x => x.ToModel()).ToList();
return Ok(result);
}
[Authorize("read:request")]
[HttpGet]

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("comissions.app.database.migrator")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+04861b6b58dd552f5a309afc249a59707799da37")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+eb12979506b15d0d3d9c5d48495f2de33177c372")]
[assembly: System.Reflection.AssemblyProductAttribute("comissions.app.database.migrator")]
[assembly: System.Reflection.AssemblyTitleAttribute("comissions.app.database.migrator")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
f6d1d126af9b4482ad74b31893663f1ef7fa48b4f281e3af0a28cd303ade7752
325704a87e5f919366972ec155ee77505b690697d416344ba0395d4156a9b548

View File

@ -1 +1 @@
17077084151680581
17086505533886000