mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-25 23:18:56 -07:00
Radicade Public Code
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using RadicadeServer.DB;
|
||||
using RadicadeServer.Extensions;
|
||||
using RadicadeServer.RecNet.Enums.Inventions;
|
||||
using RadicadeServer.RecNet.Inventions;
|
||||
|
||||
namespace RadicadeServer.API.Inventions.V3
|
||||
{
|
||||
[Route("api/inventions/v3")]
|
||||
public class InventionsV3(RecDBContext db) : Controller
|
||||
{
|
||||
[HttpGet("publish"), Authorize]
|
||||
public async Task<FullInvention?> PublishInvention([FromQuery] long inventionId, [FromQuery] InventionRole permissionLevel, [FromQuery] int? price)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
|
||||
var invention = await db.Inventions.FirstOrDefaultAsync(x => x.CreatorPlayerId == userId && x.InventionId == inventionId);
|
||||
if (invention == null) return null;
|
||||
|
||||
invention.IsPublished = true;
|
||||
invention.HideFromPlayer = false;
|
||||
|
||||
if (price.HasValue)
|
||||
invention.Price = price.Value;
|
||||
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
return await invention.ToFullInvention(db);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user