diff --git a/src/comissions.app.api/Controllers/DiscoveryController.cs b/src/comissions.app.api/Controllers/DiscoveryController.cs index 6473a20..413786f 100644 --- a/src/comissions.app.api/Controllers/DiscoveryController.cs +++ b/src/comissions.app.api/Controllers/DiscoveryController.cs @@ -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 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 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}")] diff --git a/src/comissions.app.api/Models/PenaltyModel.cs b/src/comissions.app.api/Models/PenaltyModel.cs new file mode 100644 index 0000000..fafcd6e --- /dev/null +++ b/src/comissions.app.api/Models/PenaltyModel.cs @@ -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 + }; + } +} \ No newline at end of file