✨ Update sticker controller
This commit is contained in:
@@ -339,6 +339,21 @@ public class StickerController(AppDatabase db, StickerService st, FileService.Fi
|
|||||||
return Ok(sticker);
|
return Ok(sticker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("{packId:guid}/own")]
|
||||||
|
[Authorize]
|
||||||
|
public async Task<ActionResult<StickerPackOwnership>> GetStickerPackOwnership(Guid packId)
|
||||||
|
{
|
||||||
|
if (HttpContext.Items["CurrentUser"] is not Account currentUser)
|
||||||
|
return Unauthorized();
|
||||||
|
var accountId = Guid.Parse(currentUser.Id);
|
||||||
|
|
||||||
|
var ownership = await db.StickerPackOwnerships
|
||||||
|
.Where(p => p.PackId == packId && p.AccountId == accountId)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (ownership is null) return NotFound();
|
||||||
|
return Ok(ownership);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost("{packId:guid}/own")]
|
[HttpPost("{packId:guid}/own")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<ActionResult<StickerPackOwnership>> AcquireStickerPack([FromRoute] Guid packId)
|
public async Task<ActionResult<StickerPackOwnership>> AcquireStickerPack([FromRoute] Guid packId)
|
||||||
@@ -351,6 +366,11 @@ public class StickerController(AppDatabase db, StickerService st, FileService.Fi
|
|||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
if (pack is null) return NotFound();
|
if (pack is null) return NotFound();
|
||||||
|
|
||||||
|
var existingOwnership = await db.StickerPackOwnerships
|
||||||
|
.Where(p => p.PackId == packId && p.AccountId == Guid.Parse(currentUser.Id))
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (existingOwnership is not null) return Ok(existingOwnership);
|
||||||
|
|
||||||
var ownership = new StickerPackOwnership
|
var ownership = new StickerPackOwnership
|
||||||
{
|
{
|
||||||
PackId = packId,
|
PackId = packId,
|
||||||
|
Reference in New Issue
Block a user