mirror of
https://github.com/D4M13N-D3V/comissions-app-core-api.git
synced 2025-03-14 10:04:55 +00:00
added more control to request listing
This commit is contained in:
parent
eb12979506
commit
6908225f21
@ -35,7 +35,7 @@ public class RequestsController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Route("PaymentWebhook")]
|
[Route("PaymentWebhook")]
|
||||||
[HttpPost]
|
[HttpPost ]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public async Task<IActionResult> ProcessWebhookEvent()
|
public async Task<IActionResult> ProcessWebhookEvent()
|
||||||
{
|
{
|
||||||
@ -664,18 +664,46 @@ public class RequestsController : Controller
|
|||||||
[Authorize("read:request")]
|
[Authorize("read:request")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("Customer/Requests")]
|
[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 userId = User.GetUserId();
|
||||||
var requests = await _dbContext.Requests
|
var query = _dbContext.Requests
|
||||||
.Where(x=>x.UserId==userId)
|
.Where(x => x.UserId == userId);
|
||||||
.Include(x=>x.Artist)
|
|
||||||
.Where(x=>x.Artist.Name.Contains(search) || x.Message.Contains(search))
|
if (completed)
|
||||||
.Skip(offset).Take(pageSize).ToListAsync();
|
{
|
||||||
var result = requests.Select(x=>x.ToModel()).ToList();
|
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);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Authorize("read:request")]
|
[Authorize("read:request")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("Customer/Requests/{requestId:int}")]
|
[Route("Customer/Requests/{requestId:int}")]
|
||||||
|
@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("comissions.app.database.migrator")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("comissions.app.database.migrator")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[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.AssemblyProductAttribute("comissions.app.database.migrator")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("comissions.app.database.migrator")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("comissions.app.database.migrator")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
@ -1 +1 @@
|
|||||||
f6d1d126af9b4482ad74b31893663f1ef7fa48b4f281e3af0a28cd303ade7752
|
325704a87e5f919366972ec155ee77505b690697d416344ba0395d4156a9b548
|
||||||
|
@ -1 +1 @@
|
|||||||
17077084151680581
|
17086505533886000
|
Loading…
x
Reference in New Issue
Block a user