mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Refactor controllers to use [FromBody] attribute for DTO parameters and update return types for consistency
This commit is contained in:
@@ -73,7 +73,7 @@ public class DocumentCompaniesController(MarechaiContext context) : ControllerBa
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult> UpdateAsync(DocumentCompanyDto dto)
|
||||
public async Task<ActionResult> UpdateAsync([FromBody] DocumentCompanyDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -95,7 +95,7 @@ public class DocumentCompaniesController(MarechaiContext context) : ControllerBa
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<int>> CreateAsync(DocumentCompanyDto dto)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] DocumentCompanyDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public class DocumentPeopleController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult> UpdateAsync(DocumentPersonDto dto)
|
||||
public async Task<ActionResult> UpdateAsync([FromBody] DocumentPersonDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -104,7 +104,7 @@ public class DocumentPeopleController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<int>> CreateAsync(DocumentPersonDto dto)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] DocumentPersonDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ public class DocumentScansController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult> UpdateAsync(DocumentScanDto dto)
|
||||
public async Task<ActionResult> UpdateAsync([FromBody] DocumentScanDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -115,7 +115,7 @@ public class DocumentScansController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<Guid>> CreateAsync(DocumentScanDto dto)
|
||||
public async Task<ActionResult<Guid>> CreateAsync([FromBody] DocumentScanDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ public class DocumentsByMachineController(MarechaiContext context) : ControllerB
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(int machineId, long bookId)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] DocumentByMachineDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -91,8 +91,8 @@ public class DocumentsByMachineController(MarechaiContext context) : ControllerB
|
||||
|
||||
var item = new DocumentsByMachine
|
||||
{
|
||||
MachineId = machineId,
|
||||
DocumentId = bookId
|
||||
MachineId = dto.MachineId,
|
||||
DocumentId = dto.DocumentId
|
||||
};
|
||||
|
||||
await context.DocumentsByMachines.AddAsync(item);
|
||||
|
||||
@@ -82,7 +82,7 @@ public class DocumentsByMachineFamilyController(MarechaiContext context) : Contr
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(int machineFamilyId, long bookId)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] DocumentByMachineFamilyDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -90,8 +90,8 @@ public class DocumentsByMachineFamilyController(MarechaiContext context) : Contr
|
||||
|
||||
var item = new DocumentsByMachineFamily
|
||||
{
|
||||
MachineFamilyId = machineFamilyId,
|
||||
DocumentId = bookId
|
||||
MachineFamilyId = dto.MachineFamilyId,
|
||||
DocumentId = dto.DocumentId
|
||||
};
|
||||
|
||||
await context.DocumentsByMachineFamilies.AddAsync(item);
|
||||
|
||||
@@ -82,7 +82,7 @@ public class DocumentsController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult> UpdateAsync(DocumentDto dto)
|
||||
public async Task<ActionResult> UpdateAsync([FromBody] DocumentDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -106,7 +106,7 @@ public class DocumentsController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(DocumentDto dto)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] DocumentDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public class DumpsController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult> UpdateAsync(DumpDto dto)
|
||||
public async Task<ActionResult> UpdateAsync([FromBody] DumpDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -112,7 +112,7 @@ public class DumpsController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<ulong>> CreateAsync(DumpDto dto)
|
||||
public async Task<ActionResult<ulong>> CreateAsync([FromBody] DumpDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public class GpusByMachineController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(int gpuId, int machineId)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] GpuByMachineDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -93,8 +93,8 @@ public class GpusByMachineController(MarechaiContext context) : ControllerBase
|
||||
|
||||
var item = new GpusByMachine
|
||||
{
|
||||
GpuId = gpuId,
|
||||
MachineId = machineId
|
||||
GpuId = dto.GpuId,
|
||||
MachineId = dto.MachineId
|
||||
};
|
||||
|
||||
await context.GpusByMachine.AddAsync(item);
|
||||
|
||||
@@ -137,7 +137,7 @@ public class GpusController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<int>> CreateAsync(GpuDto dto)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] GpuDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public class InstructionSetExtensionsByProcessorController(MarechaiContext conte
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<int>> CreateAsync(int processorId, int extensionId)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] InstructionSetExtensionByProcessorDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -92,8 +92,8 @@ public class InstructionSetExtensionsByProcessorController(MarechaiContext conte
|
||||
|
||||
var item = new InstructionSetExtensionsByProcessor
|
||||
{
|
||||
ProcessorId = processorId,
|
||||
ExtensionId = extensionId
|
||||
ProcessorId = dto.ProcessorId,
|
||||
ExtensionId = dto.ExtensionId
|
||||
};
|
||||
|
||||
await context.InstructionSetExtensionsByProcessor.AddAsync(item);
|
||||
|
||||
@@ -91,7 +91,7 @@ public class InstructionSetExtensionsController(MarechaiContext context) : Contr
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<int>> CreateAsync(InstructionSetExtension viewModel)
|
||||
public async Task<ActionResult<int>> CreateAsync([FromBody] InstructionSetExtension viewModel)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public class InstructionSetsController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<int>> CreateAsync(InstructionSet viewModel)
|
||||
public async Task<ActionResult<int>> CreateAsync([FromBody] InstructionSet viewModel)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ public class LicensesController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<int>> CreateAsync(License viewModel)
|
||||
public async Task<ActionResult<int>> CreateAsync([FromBody] License viewModel)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ public class MachineFamiliesController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<int>> CreateAsync(MachineFamilyDto dto)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] MachineFamilyDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ public class MachinePhotosController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<Guid>> CreateAsync(MachinePhotoDto dto)
|
||||
public async Task<ActionResult<Guid>> CreateAsync([FromBody] MachinePhotoDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ public class MachinesController
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<int>> CreateAsync(MachineDto dto)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] MachineDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ public class MagazineIssuesController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(MagazineIssueDto dto)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] MagazineIssueDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ public class MagazineScansController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<Guid>> CreateAsync(MagazineScanDto dto)
|
||||
public async Task<ActionResult<Guid>> CreateAsync([FromBody] MagazineScanDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ public class MagazinesByMachineController(MarechaiContext context) : ControllerB
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(int machineId, long bookId)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] MagazineByMachineDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -91,8 +91,8 @@ public class MagazinesByMachineController(MarechaiContext context) : ControllerB
|
||||
|
||||
var item = new MagazinesByMachine
|
||||
{
|
||||
MachineId = machineId,
|
||||
MagazineId = bookId
|
||||
MachineId = dto.MachineId,
|
||||
MagazineId = dto.MagazineId
|
||||
};
|
||||
|
||||
await context.MagazinesByMachines.AddAsync(item);
|
||||
|
||||
@@ -83,7 +83,7 @@ public class MagazinesByMachineFamilyController(MarechaiContext context) : Contr
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(int machineFamilyId, long bookId)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] MagazineByMachineFamilyDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -91,8 +91,8 @@ public class MagazinesByMachineFamilyController(MarechaiContext context) : Contr
|
||||
|
||||
var item = new MagazinesByMachineFamily
|
||||
{
|
||||
MachineFamilyId = machineFamilyId,
|
||||
MagazineId = bookId
|
||||
MachineFamilyId = dto.MachineFamilyId,
|
||||
MagazineId = dto.MagazineId
|
||||
};
|
||||
|
||||
await context.MagazinesByMachinesFamilies.AddAsync(item);
|
||||
|
||||
@@ -122,7 +122,7 @@ public class MagazinesController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(MagazineDto dto)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] MagazineDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ public class MediaController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<ulong>> CreateAsync(MediaDto dto)
|
||||
public async Task<ActionResult<ulong>> CreateAsync([FromBody] MediaDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Marechai.Data.Dtos;
|
||||
using Marechai.Database;
|
||||
using Marechai.Database.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -89,8 +88,7 @@ public class MemoriesByMachineController(MarechaiContext context) : ControllerBa
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(int machineId, MemoryType type, MemoryUsage usage, long? size,
|
||||
double? speed)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] MemoryByMachineDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -98,11 +96,11 @@ public class MemoriesByMachineController(MarechaiContext context) : ControllerBa
|
||||
|
||||
var item = new MemoryByMachine
|
||||
{
|
||||
MachineId = machineId,
|
||||
Type = type,
|
||||
Usage = usage,
|
||||
Size = size,
|
||||
Speed = speed
|
||||
MachineId = dto.MachineId,
|
||||
Type = dto.Type,
|
||||
Usage = dto.Usage,
|
||||
Size = dto.Size,
|
||||
Speed = dto.Speed
|
||||
};
|
||||
|
||||
await context.MemoryByMachine.AddAsync(item);
|
||||
|
||||
@@ -89,7 +89,7 @@ public class PeopleByBookController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(int personId, long bookId, string roleId)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] PersonByBookDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -97,9 +97,9 @@ public class PeopleByBookController(MarechaiContext context) : ControllerBase
|
||||
|
||||
var item = new PeopleByBook
|
||||
{
|
||||
PersonId = personId,
|
||||
BookId = bookId,
|
||||
RoleId = roleId
|
||||
PersonId = dto.PersonId,
|
||||
BookId = dto.BookId,
|
||||
RoleId = dto.RoleId
|
||||
};
|
||||
|
||||
await context.PeopleByBooks.AddAsync(item);
|
||||
|
||||
@@ -89,7 +89,7 @@ public class PeopleByDocumentController(MarechaiContext context) : ControllerBas
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(int personId, long documentId, string roleId)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] PersonByDocumentDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -97,9 +97,9 @@ public class PeopleByDocumentController(MarechaiContext context) : ControllerBas
|
||||
|
||||
var item = new PeopleByDocument
|
||||
{
|
||||
PersonId = personId,
|
||||
DocumentId = documentId,
|
||||
RoleId = roleId
|
||||
PersonId = dto.PersonId,
|
||||
DocumentId = dto.DocumentId,
|
||||
RoleId = dto.RoleId
|
||||
};
|
||||
|
||||
await context.PeopleByDocuments.AddAsync(item);
|
||||
|
||||
@@ -89,7 +89,7 @@ public class PeopleByMagazineController(MarechaiContext context) : ControllerBas
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(int personId, long magazineId, string roleId)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] PersonByMagazineDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -97,9 +97,9 @@ public class PeopleByMagazineController(MarechaiContext context) : ControllerBas
|
||||
|
||||
var item = new PeopleByMagazine
|
||||
{
|
||||
PersonId = personId,
|
||||
MagazineId = magazineId,
|
||||
RoleId = roleId
|
||||
PersonId = dto.PersonId,
|
||||
MagazineId = dto.MagazineId,
|
||||
RoleId = dto.RoleId
|
||||
};
|
||||
|
||||
await context.PeopleByMagazines.AddAsync(item);
|
||||
|
||||
@@ -124,7 +124,7 @@ public class PeopleController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<int>> CreateAsync(PersonDto dto)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] PersonDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ public class ProcessorsByMachineController(MarechaiContext context) : Controller
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(int processorId, int machineId, float? speed)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] ProcessorByMachineDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -94,9 +94,9 @@ public class ProcessorsByMachineController(MarechaiContext context) : Controller
|
||||
|
||||
var item = new ProcessorsByMachine
|
||||
{
|
||||
ProcessorId = processorId,
|
||||
MachineId = machineId,
|
||||
Speed = speed
|
||||
ProcessorId = dto.ProcessorId,
|
||||
MachineId = dto.MachineId,
|
||||
Speed = dto.Speed
|
||||
};
|
||||
|
||||
await context.ProcessorsByMachine.AddAsync(item);
|
||||
|
||||
@@ -210,7 +210,7 @@ public class ProcessorsController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<int>> CreateAsync(ProcessorDto dto)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] ProcessorDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ public class ResolutionsByGpuController(MarechaiContext context) : ControllerBas
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(int resolutionId, int gpuId)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] ResolutionByGpuDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -109,8 +109,8 @@ public class ResolutionsByGpuController(MarechaiContext context) : ControllerBas
|
||||
|
||||
var item = new ResolutionsByGpu
|
||||
{
|
||||
GpuId = gpuId,
|
||||
ResolutionId = resolutionId
|
||||
GpuId = dto.GpuId,
|
||||
ResolutionId = dto.ResolutionId
|
||||
};
|
||||
|
||||
await context.ResolutionsByGpu.AddAsync(item);
|
||||
|
||||
@@ -97,7 +97,7 @@ public class ResolutionsByScreenController(MarechaiContext context) : Controller
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(int resolutionId, int screenId)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] ResolutionByScreenDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -105,8 +105,8 @@ public class ResolutionsByScreenController(MarechaiContext context) : Controller
|
||||
|
||||
var item = new ResolutionsByScreen
|
||||
{
|
||||
ScreenId = screenId,
|
||||
ResolutionId = resolutionId
|
||||
ScreenId = dto.ScreenId,
|
||||
ResolutionId = dto.ResolutionId
|
||||
};
|
||||
|
||||
await context.ResolutionsByScreen.AddAsync(item);
|
||||
|
||||
@@ -111,7 +111,7 @@ public class ResolutionsController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<int>> CreateAsync(ResolutionDto dto)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] ResolutionDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -101,17 +101,17 @@ public class ScreensByMachineController(MarechaiContext context) : ControllerBas
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(int machineId, int screenId)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] ScreenByMachineDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return Unauthorized();
|
||||
if(context.ScreensByMachine.Any(s => s.MachineId == machineId && s.ScreenId == screenId)) return 0;
|
||||
if(context.ScreensByMachine.Any(s => s.MachineId == dto.MachineId && s.ScreenId == dto.ScreenId)) return 0;
|
||||
|
||||
var item = new ScreensByMachine
|
||||
{
|
||||
ScreenId = screenId,
|
||||
MachineId = machineId
|
||||
ScreenId = dto.ScreenId,
|
||||
MachineId = dto.MachineId
|
||||
};
|
||||
|
||||
await context.ScreensByMachine.AddAsync(item);
|
||||
|
||||
@@ -134,7 +134,7 @@ public class ScreensController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<int>> CreateAsync(ScreenDto dto)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] ScreenDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ public class SoftwareFamiliesController(MarechaiContext context) : ControllerBas
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<ulong>> CreateAsync(SoftwareFamilyDto dto)
|
||||
public async Task<ActionResult<ulong>> CreateAsync([FromBody] SoftwareFamilyDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ public class SoftwareVariantsController(MarechaiContext context) : ControllerBas
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<ulong>> CreateAsync(SoftwareVariantDto dto)
|
||||
public async Task<ActionResult<ulong>> CreateAsync([FromBody] SoftwareVariantDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ public class SoftwareVersionsController(MarechaiContext context) : ControllerBas
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<ulong>> CreateAsync(SoftwareVersionDto dto)
|
||||
public async Task<ActionResult<ulong>> CreateAsync([FromBody] SoftwareVersionDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public class SoundSynthsByMachineController(MarechaiContext context) : Controlle
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(int soundSynthId, int machineId)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] SoundSynthByMachineDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -93,8 +93,8 @@ public class SoundSynthsByMachineController(MarechaiContext context) : Controlle
|
||||
|
||||
var item = new SoundByMachine
|
||||
{
|
||||
SoundSynthId = soundSynthId,
|
||||
MachineId = machineId
|
||||
SoundSynthId = dto.SoundSynthId,
|
||||
MachineId = dto.MachineId
|
||||
};
|
||||
|
||||
await context.SoundByMachine.AddAsync(item);
|
||||
|
||||
@@ -149,7 +149,7 @@ public class SoundSynthsController(MarechaiContext context) : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<int>> CreateAsync(SoundSynthDto dto)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] SoundSynthDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Marechai.Data.Dtos;
|
||||
using Marechai.Database;
|
||||
using Marechai.Database.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -87,8 +86,7 @@ public class StorageByMachineController(MarechaiContext context) : ControllerBas
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<ActionResult<long>> CreateAsync(int machineId, StorageType type, StorageInterface @interface,
|
||||
long? capacity)
|
||||
public async Task<ActionResult<long>> CreateAsync([FromBody] StorageByMachineDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
@@ -96,10 +94,10 @@ public class StorageByMachineController(MarechaiContext context) : ControllerBas
|
||||
|
||||
var item = new StorageByMachine
|
||||
{
|
||||
MachineId = machineId,
|
||||
Type = type,
|
||||
Interface = @interface,
|
||||
Capacity = capacity
|
||||
MachineId = dto.MachineId,
|
||||
Type = dto.Type,
|
||||
Interface = dto.Interface,
|
||||
Capacity = dto.Capacity
|
||||
};
|
||||
|
||||
await context.StorageByMachine.AddAsync(item);
|
||||
|
||||
Reference in New Issue
Block a user