mirror of
				https://github.com/D4M13N-D3V/comissions-app-core-api.git
				synced 2025-10-31 01:25:27 +00:00 
			
		
		
		
	feat: added endpoints for getting requests on admin endpoints for users and artists
This commit is contained in:
		
							parent
							
								
									e36a578eba
								
							
						
					
					
						commit
						f9731d9445
					
				| @ -1,6 +1,7 @@ | |||||||
| using comissions.app.api.Extensions; | using comissions.app.api.Extensions; | ||||||
| using comissions.app.database; | using comissions.app.database; | ||||||
| using comissions.app.database.Models.Admin; | using comissions.app.database.Models.Admin; | ||||||
|  | using comissions.app.database.Models.Request; | ||||||
| using Microsoft.AspNetCore.Authorization; | using Microsoft.AspNetCore.Authorization; | ||||||
| using Microsoft.AspNetCore.Http.HttpResults; | using Microsoft.AspNetCore.Http.HttpResults; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
| @ -57,6 +58,38 @@ public class AdminArtistsController:ControllerBase | |||||||
|         return Ok(result); |         return Ok(result); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |     [HttpGet("{sellerId:int}/Requests")] | ||||||
|  |     public async Task<IActionResult> GetArtistRequests(int sellerId, [FromQuery]int offset = 0, [FromQuery]int pageSize = 10) | ||||||
|  |     { | ||||||
|  |         var requests = await _dbContext.Requests | ||||||
|  |             .Include(x=>x.Artist) | ||||||
|  |             .Where(x=>x.ArtistId==sellerId) | ||||||
|  |             .Skip(offset).Take(pageSize).ToListAsync(); | ||||||
|  |         var result = requests.Select(x=>x.ToModel()); | ||||||
|  |         return Ok(result); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     [HttpGet("{sellerId:int}/Requests/{requestId:int")] | ||||||
|  |     public async Task<IActionResult> GetArtistRequest(int sellerId, int requestId) | ||||||
|  |     { | ||||||
|  |         var request = await _dbContext.Requests | ||||||
|  |             .Include(x=>x.Artist) | ||||||
|  |             .FirstOrDefaultAsync(x=>x.Id==requestId); | ||||||
|  |         if(request==null) | ||||||
|  |             return NotFound(); | ||||||
|  |         var result = request.ToModel(); | ||||||
|  |         return Ok(result); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     [HttpGet("{sellerId:int}/Requests/Count")] | ||||||
|  |     public async Task<IActionResult> GetArtistRequestsCount(int sellerId) | ||||||
|  |     { | ||||||
|  |         var result = await _dbContext.Requests | ||||||
|  |             .Where(x=>x.ArtistId==sellerId) | ||||||
|  |             .CountAsync(); | ||||||
|  |         return Ok(result); | ||||||
|  |     } | ||||||
|  |      | ||||||
|      |      | ||||||
|     [HttpPut("{sellerId:int}/Terminate")] |     [HttpPut("{sellerId:int}/Terminate")] | ||||||
|     public async Task<IActionResult> TerminateArtist(int sellerId) |     public async Task<IActionResult> TerminateArtist(int sellerId) | ||||||
|  | |||||||
| @ -2,6 +2,7 @@ using comissions.app.api.Extensions; | |||||||
| using comissions.app.database; | using comissions.app.database; | ||||||
| using comissions.app.database.Entities; | using comissions.app.database.Entities; | ||||||
| using comissions.app.database.Models.Admin; | using comissions.app.database.Models.Admin; | ||||||
|  | using comissions.app.database.Models.Request; | ||||||
| using Microsoft.AspNetCore.Authorization; | using Microsoft.AspNetCore.Authorization; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
| using Microsoft.EntityFrameworkCore; | using Microsoft.EntityFrameworkCore; | ||||||
| @ -34,6 +35,39 @@ public class AdminUsersController:ControllerBase | |||||||
|         return Ok(result); |         return Ok(result); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |     [HttpGet("{userId}/Requests")] | ||||||
|  |     public async Task<IActionResult> GetUserRequests(string artistId, [FromQuery]int offset = 0, [FromQuery]int pageSize = 10) | ||||||
|  |     { | ||||||
|  |         var requests = await _dbContext.Requests | ||||||
|  |             .Include(x=>x.Artist) | ||||||
|  |             .Where(x=>x.UserId==artistId) | ||||||
|  |             .Skip(offset).Take(pageSize).ToListAsync(); | ||||||
|  |         var result = requests.Select(x=>x.ToModel()); | ||||||
|  |         return Ok(result); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     [HttpGet("{userId}/Requests/{requestId:int")] | ||||||
|  |     public async Task<IActionResult> GetUserRequest(string artistId, int requestId) | ||||||
|  |     { | ||||||
|  |         var request = await _dbContext.Requests | ||||||
|  |             .Include(x=>x.Artist) | ||||||
|  |             .FirstOrDefaultAsync(x=>x.Id==requestId); | ||||||
|  |         if(request==null) | ||||||
|  |             return NotFound(); | ||||||
|  |         var result = request.ToModel(); | ||||||
|  |         return Ok(result); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     [HttpGet("{userId}/Requests/Count")] | ||||||
|  |     public async Task<IActionResult> GetUserRequestsCount(string artistId) | ||||||
|  |     { | ||||||
|  |         var result = await _dbContext.Requests | ||||||
|  |             .Where(x=>x.UserId==artistId) | ||||||
|  |             .CountAsync(); | ||||||
|  |         return Ok(result); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |      | ||||||
|     [HttpGet("Count")] |     [HttpGet("Count")] | ||||||
|     public async Task<IActionResult> GetUsersCount([FromQuery]string search="") |     public async Task<IActionResult> GetUsersCount([FromQuery]string search="") | ||||||
|     { |     { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Damien Ostler
						Damien Ostler