mirror of
https://github.com/D4M13N-D3V/comissions-app-core-api.git
synced 2025-03-14 10:04:55 +00:00
fix: changed endpoints back and added endpoint to get the user by their name
This commit is contained in:
parent
b919942705
commit
dcca20068e
@ -48,67 +48,16 @@ public class DiscoveryController : Controller
|
|||||||
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("Artists/{sellerName}/Page")]
|
[Route("Artists/{sellerName}")]
|
||||||
public async Task<IActionResult> GetArtistPage(string sellerName)
|
public async Task<IActionResult> GetArtistByName(string sellerName)
|
||||||
{
|
{
|
||||||
var seller = await _dbContext.UserArtists
|
|
||||||
.Include(x=>x.ArtistPageSettings)
|
var seller = await _dbContext.UserArtists.Include(x=>x.User)
|
||||||
.FirstOrDefaultAsync(x=>x.Name==sellerName.Replace('-', ' '));
|
.FirstOrDefaultAsync(x=>x.User.DisplayName==sellerName);
|
||||||
if(seller==null)
|
if(seller==null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
var result = seller.ToModel();
|
||||||
if (seller.ArtistPageSettings == null)
|
return Ok(result);
|
||||||
{
|
|
||||||
var newSettings = new ArtistPageSettings()
|
|
||||||
{
|
|
||||||
ArtistId = seller.Id,
|
|
||||||
BackgroundColor = "rgb(126, 115, 115)",
|
|
||||||
HeaderColor = "rgb(194, 187, 187)",
|
|
||||||
HeaderTextSize = 5,
|
|
||||||
HeaderUseImage = false,
|
|
||||||
HeaderImageUrl = "",
|
|
||||||
DescriptionHeaderText = "",
|
|
||||||
DescriptionHeaderColor = "rgb(194, 187, 187)",
|
|
||||||
DescriptionHeaderSize = 3,
|
|
||||||
DescriptionHeaderUseImage = false,
|
|
||||||
DescriptionHeaderImageUrl = "",
|
|
||||||
DescriptionBackgroundColor = "rgb(103, 97, 97)",
|
|
||||||
DescriptionTextColor = "rgb(186, 186, 186)",
|
|
||||||
DescriptionTextSize = 1,
|
|
||||||
PortfolionHeaderText = "",
|
|
||||||
PortfolionHeaderColor = "rgb(194, 187, 187)",
|
|
||||||
PortfolionHeaderSize = 3,
|
|
||||||
PortfolionHeaderUseImage = false,
|
|
||||||
PortfolionHeaderImageUrl = "",
|
|
||||||
PortfolioBackgroundColor = "rgb(78, 73, 73)",
|
|
||||||
PortfolioMasonry = true,
|
|
||||||
PortfolioColumns = 3,
|
|
||||||
PortfolioEnabledScrolling = true,
|
|
||||||
PortfolioMaximumSize = 50,
|
|
||||||
RequestHeaderText = "",
|
|
||||||
RequestHeaderColor = "rgb(194, 187, 187)",
|
|
||||||
RequestHeaderSize = 3,
|
|
||||||
RequestHeaderUseImage = false,
|
|
||||||
RequestHeaderImageUrl = "",
|
|
||||||
RequestBackgroundColor = "rgb(103, 97, 97)",
|
|
||||||
RequestTermsColor = "rgb(194, 187, 187)",
|
|
||||||
RequestButtonBGColor = "rgb(101, 97, 97)",
|
|
||||||
RequestButtonTextColor = "rgb(194, 187, 187)",
|
|
||||||
RequestButtonHoverBGColor = "rgb(98, 98, 98)"
|
|
||||||
};
|
|
||||||
var dbSettings = _dbContext.ArtistPageSettings.Add(newSettings).Entity;
|
|
||||||
await _dbContext.SaveChangesAsync();
|
|
||||||
var result = dbSettings.ToModel();
|
|
||||||
result.Artist = seller.ToModel();
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var result = seller.ArtistPageSettings.ToModel();
|
|
||||||
result.Artist = seller.ToModel();
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
@ -919,7 +919,7 @@ public class RequestsController : Controller
|
|||||||
.Where(x=>x.UserId==User.GetUserId())
|
.Where(x=>x.UserId==User.GetUserId())
|
||||||
.CountAsync();
|
.CountAsync();
|
||||||
|
|
||||||
var artist = await _dbContext.UserArtists.Include(x=>x.User).FirstOrDefaultAsync(x=>x.User.DisplayName==model.ArtistDisplayName);
|
var artist = await _dbContext.UserArtists.FirstOrDefaultAsync(x=>x.Id==model.ArtistId);
|
||||||
if(artist==null)
|
if(artist==null)
|
||||||
return NotFound("Artist not found.");
|
return NotFound("Artist not found.");
|
||||||
|
|
||||||
@ -932,7 +932,7 @@ public class RequestsController : Controller
|
|||||||
Message = model.Message,
|
Message = model.Message,
|
||||||
RequestDate = DateTime.UtcNow,
|
RequestDate = DateTime.UtcNow,
|
||||||
UserId = userId,
|
UserId = userId,
|
||||||
ArtistId = artist.Id,
|
ArtistId = model.ArtistId,
|
||||||
Accepted = false,
|
Accepted = false,
|
||||||
AcceptedDate = null,
|
AcceptedDate = null,
|
||||||
Declined = false,
|
Declined = false,
|
||||||
|
@ -2,7 +2,7 @@ namespace comissions.app.database.Models.Request;
|
|||||||
|
|
||||||
public class RequestCreateModel
|
public class RequestCreateModel
|
||||||
{
|
{
|
||||||
public string ArtistDisplayName { get; set; }
|
public int ArtistId { get; set; }
|
||||||
public string Message { get; set; }
|
public string Message { get; set; }
|
||||||
public decimal Amount { get; set; }
|
public decimal Amount { get; set; }
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user