mirror of
https://github.com/D4M13N-D3V/comissions-app-core-api.git
synced 2025-06-15 20:59:07 +00:00
fix: added count endpoints for customer and artist requests
This commit is contained in:
parent
a39baba9c5
commit
f076349307
@ -702,6 +702,41 @@ public class RequestsController : Controller
|
||||
var result = requests.Select(x => x.ToModel()).ToList();
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("Customer/Count")]
|
||||
public async Task<IActionResult> GetRequestCount([FromQuery]bool completed = true, [FromQuery]bool declined = true, [FromQuery]bool accepted = true, [FromQuery]bool paid = true,
|
||||
string search="")
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
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 result = query.Count();
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
||||
[Authorize("read:request")]
|
||||
@ -762,6 +797,42 @@ public class RequestsController : Controller
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[Authorize("read:request")]
|
||||
[HttpGet]
|
||||
[Route("Artist/Count")]
|
||||
public async Task<IActionResult> GetArtistRequestCount([FromQuery]bool completed = true, [FromQuery]bool declined = true, [FromQuery]bool accepted = true, [FromQuery]bool paid = true,
|
||||
string search="")
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var query = _dbContext.Requests.Include(x=>x.Artist)
|
||||
.Where(x => x.Artist.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 result = query.Count();
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[Authorize("read:request")]
|
||||
[HttpGet]
|
||||
[Route("Artist/{requestId:int}")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user