mirror of
https://github.com/D4M13N-D3V/comissions-app-core-api.git
synced 2025-03-14 10:04:55 +00:00
fix: added endpoints to discovery controller for users to see w hypeople have been banned or suspended
This commit is contained in:
parent
a3f137cb12
commit
40653eff04
@ -3,6 +3,7 @@ using comissions.app.api.Models.PortfolioModel;
|
||||
using comissions.app.api.Services.Storage;
|
||||
using comissions.app.database;
|
||||
using comissions.app.database.Entities;
|
||||
using comissions.app.database.Models;
|
||||
using comissions.app.database.Models.Request;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@ -47,6 +48,34 @@ public class DiscoveryController : Controller
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("Artists/{sellerId:int}/Bans")]
|
||||
public async Task<IActionResult> GetArtistBans(int sellerId)
|
||||
{
|
||||
var seller = await _dbContext.UserArtists
|
||||
.Include(x=>x.User).ThenInclude(x=>x.Requests)
|
||||
.Include(x=>x.User).ThenInclude(x=>x.Bans)
|
||||
.FirstOrDefaultAsync(x=>x.Id==sellerId);
|
||||
if(seller==null)
|
||||
return NotFound();
|
||||
var result = seller.User.Bans.Select(x=>x.ToModel()).ToList();
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("Artists/{sellerId:int}/Suspensions")]
|
||||
public async Task<IActionResult> GetArtistSuspensions(int sellerId)
|
||||
{
|
||||
var seller = await _dbContext.UserArtists
|
||||
.Include(x=>x.User).ThenInclude(x=>x.Suspensions)
|
||||
.Include(x=>x.User).ThenInclude(x=>x.Bans)
|
||||
.FirstOrDefaultAsync(x=>x.Id==sellerId);
|
||||
if(seller==null)
|
||||
return NotFound();
|
||||
var result = seller.User.Suspensions.Select(x=>x.ToModel()).ToList();
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
[Route("Artists/{sellerName}")]
|
||||
|
33
src/comissions.app.api/Models/PenaltyModel.cs
Normal file
33
src/comissions.app.api/Models/PenaltyModel.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using comissions.app.database.Entities;
|
||||
|
||||
namespace comissions.app.database.Models;
|
||||
|
||||
public class PenaltyModel
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
public string Reason { get; set; }
|
||||
public string Admin { get; set; }
|
||||
}
|
||||
|
||||
public static class PenaltyModelExtensions
|
||||
{
|
||||
public static PenaltyModel ToModel(this Ban ban)
|
||||
{
|
||||
return new PenaltyModel()
|
||||
{
|
||||
Date = ban.BanDate,
|
||||
Reason = ban.Reason,
|
||||
Admin = ban.Admin.DisplayName
|
||||
};
|
||||
}
|
||||
|
||||
public static PenaltyModel ToModel(this Suspension suspension)
|
||||
{
|
||||
return new PenaltyModel()
|
||||
{
|
||||
Date = suspension.SuspensionDate,
|
||||
Reason = suspension.Reason,
|
||||
Admin = suspension.Admin.DisplayName
|
||||
};
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user