mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Refactor controller methods to use synchronous Task return types for improved readability
This commit is contained in:
@@ -34,7 +34,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -53,7 +52,7 @@ public class BookScansController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<BookScanDto> GetAsync(Guid id) => await context.BookScans.Where(p => p.Id == id)
|
||||
public Task<BookScanDto> GetAsync(Guid id) => context.BookScans.Where(p => p.Id == id)
|
||||
.Select(p => new BookScanDto
|
||||
{
|
||||
Author = p.Author,
|
||||
@@ -62,23 +61,18 @@ public class BookScansController(MarechaiContext context) : ControllerBase
|
||||
Comments = p.Comments,
|
||||
CreationDate = p.CreationDate,
|
||||
ExifVersion = p.ExifVersion,
|
||||
HorizontalResolution =
|
||||
p.HorizontalResolution,
|
||||
HorizontalResolution = p.HorizontalResolution,
|
||||
Id = p.Id,
|
||||
ResolutionUnit =
|
||||
p.ResolutionUnit,
|
||||
ResolutionUnit = p.ResolutionUnit,
|
||||
Page = p.Page,
|
||||
ScannerManufacturer =
|
||||
p.ScannerManufacturer,
|
||||
ScannerManufacturer = p.ScannerManufacturer,
|
||||
ScannerModel = p.ScannerModel,
|
||||
SoftwareUsed = p.SoftwareUsed,
|
||||
Type = p.Type,
|
||||
UploadDate = p.UploadDate,
|
||||
UserId = p.UserId,
|
||||
VerticalResolution =
|
||||
p.VerticalResolution,
|
||||
OriginalExtension =
|
||||
p.OriginalExtension
|
||||
VerticalResolution = p.VerticalResolution,
|
||||
OriginalExtension = p.OriginalExtension
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
@@ -89,6 +83,7 @@ public class BookScansController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(BookScanDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
BookScan model = await context.BookScans.FindAsync(dto.Id);
|
||||
|
||||
@@ -118,7 +113,9 @@ public class BookScansController(MarechaiContext context) : ControllerBase
|
||||
public async Task<Guid> CreateAsync(BookScanDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return null;
|
||||
|
||||
var model = new BookScan
|
||||
{
|
||||
Author = dto.Author,
|
||||
@@ -154,6 +151,7 @@ public class BookScansController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(Guid id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
BookScan item = await context.BookScans.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class BooksController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<BookDto>> GetAsync() => await context.Books.OrderBy(b => b.NativeTitle)
|
||||
public Task<List<BookDto>> GetAsync() => context.Books.OrderBy(b => b.NativeTitle)
|
||||
.ThenBy(b => b.Published)
|
||||
.ThenBy(b => b.Title)
|
||||
.Select(b => new BookDto
|
||||
@@ -70,7 +68,7 @@ public class BooksController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<BookDto> GetAsync(long id) => await context.Books.Where(b => b.Id == id)
|
||||
public Task<BookDto> GetAsync(long id) => context.Books.Where(b => b.Id == id)
|
||||
.Select(b => new BookDto
|
||||
{
|
||||
Id = b.Id,
|
||||
@@ -95,6 +93,7 @@ public class BooksController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(BookDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Book model = await context.Books.FindAsync(dto.Id);
|
||||
|
||||
@@ -120,7 +119,9 @@ public class BooksController(MarechaiContext context) : ControllerBase
|
||||
public async Task<long> CreateAsync(BookDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new Book
|
||||
{
|
||||
Title = dto.Title,
|
||||
@@ -155,6 +156,7 @@ public class BooksController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Book item = await context.Books.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class CompaniesByBookController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<CompanyByBookDto>> GetByBook(long bookId) => await context.CompaniesByBooks
|
||||
public Task<List<CompanyByBookDto>> GetByBook(long bookId) => context.CompaniesByBooks
|
||||
.Where(p => p.BookId == bookId)
|
||||
.Select(p => new CompanyByBookDto
|
||||
{
|
||||
@@ -68,6 +66,7 @@ public class CompaniesByBookController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
CompaniesByBook item = await context.CompaniesByBooks.FindAsync(id);
|
||||
|
||||
@@ -85,7 +84,9 @@ public class CompaniesByBookController(MarechaiContext context) : ControllerBase
|
||||
public async Task<long> CreateAsync(int companyId, long bookId, string roleId)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var item = new CompaniesByBook
|
||||
{
|
||||
CompanyId = companyId,
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,8 +44,8 @@ public class CompaniesByDocumentController(MarechaiContext context) : Controller
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<CompanyByDocumentDto>> GetByDocument(long documentId) => await context
|
||||
.CompaniesByDocuments.Where(p => p.DocumentId == documentId)
|
||||
public Task<List<CompanyByDocumentDto>> GetByDocument(long documentId) => context.CompaniesByDocuments
|
||||
.Where(p => p.DocumentId == documentId)
|
||||
.Select(p => new CompanyByDocumentDto
|
||||
{
|
||||
Id = p.Id,
|
||||
@@ -68,6 +66,7 @@ public class CompaniesByDocumentController(MarechaiContext context) : Controller
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
CompaniesByDocument item = await context.CompaniesByDocuments.FindAsync(id);
|
||||
|
||||
@@ -85,7 +84,9 @@ public class CompaniesByDocumentController(MarechaiContext context) : Controller
|
||||
public async Task<long> CreateAsync(int companyId, long documentId, string roleId)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var item = new CompaniesByDocument
|
||||
{
|
||||
CompanyId = companyId,
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,8 +44,8 @@ public class CompaniesByMagazineController(MarechaiContext context) : Controller
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<CompanyByMagazineDto>> GetByMagazine(long magazineId) => await context
|
||||
.CompaniesByMagazines.Where(p => p.MagazineId == magazineId)
|
||||
public Task<List<CompanyByMagazineDto>> GetByMagazine(long magazineId) => context.CompaniesByMagazines
|
||||
.Where(p => p.MagazineId == magazineId)
|
||||
.Select(p => new CompanyByMagazineDto
|
||||
{
|
||||
Id = p.Id,
|
||||
@@ -68,6 +66,7 @@ public class CompaniesByMagazineController(MarechaiContext context) : Controller
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
CompaniesByMagazine item = await context.CompaniesByMagazines.FindAsync(id);
|
||||
|
||||
@@ -85,7 +84,9 @@ public class CompaniesByMagazineController(MarechaiContext context) : Controller
|
||||
public async Task<long> CreateAsync(int companyId, long magazineId, string roleId)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var item = new CompaniesByMagazine
|
||||
{
|
||||
CompanyId = companyId,
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -46,14 +45,13 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<CompanyDto>> GetAsync() => await context.Companies.Include(c => c.Logos)
|
||||
public Task<List<CompanyDto>> GetAsync() => context.Companies.Include(c => c.Logos)
|
||||
.OrderBy(c => c.Name)
|
||||
.Select(c => new CompanyDto
|
||||
{
|
||||
Id = c.Id,
|
||||
LastLogo =
|
||||
c.Logos
|
||||
.OrderByDescending(l => l.Year)
|
||||
c.Logos.OrderByDescending(l => l.Year)
|
||||
.FirstOrDefault()
|
||||
.Guid,
|
||||
Name = c.Name,
|
||||
@@ -70,14 +68,10 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
||||
Province = c.Province,
|
||||
PostalCode = c.PostalCode,
|
||||
Country = c.Country.Name,
|
||||
FoundedDayIsUnknown =
|
||||
c.FoundedDayIsUnknown,
|
||||
FoundedMonthIsUnknown =
|
||||
c.FoundedMonthIsUnknown,
|
||||
SoldDayIsUnknown =
|
||||
c.SoldDayIsUnknown,
|
||||
SoldMonthIsUnknown =
|
||||
c.SoldMonthIsUnknown,
|
||||
FoundedDayIsUnknown = c.FoundedDayIsUnknown,
|
||||
FoundedMonthIsUnknown = c.FoundedMonthIsUnknown,
|
||||
SoldDayIsUnknown = c.SoldDayIsUnknown,
|
||||
SoldMonthIsUnknown = c.SoldMonthIsUnknown,
|
||||
LegalName = c.LegalName
|
||||
})
|
||||
.ToListAsync();
|
||||
@@ -86,13 +80,12 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<CompanyDto> GetAsync(int id) => await context.Companies.Where(c => c.Id == id)
|
||||
public Task<CompanyDto> GetAsync(int id) => context.Companies.Where(c => c.Id == id)
|
||||
.Select(c => new CompanyDto
|
||||
{
|
||||
Id = c.Id,
|
||||
LastLogo =
|
||||
c.Logos
|
||||
.OrderByDescending(l => l.Year)
|
||||
c.Logos.OrderByDescending(l => l.Year)
|
||||
.FirstOrDefault()
|
||||
.Guid,
|
||||
Name = c.Name,
|
||||
@@ -109,14 +102,10 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
||||
Province = c.Province,
|
||||
PostalCode = c.PostalCode,
|
||||
Country = c.Country.Name,
|
||||
FoundedDayIsUnknown =
|
||||
c.FoundedDayIsUnknown,
|
||||
FoundedMonthIsUnknown =
|
||||
c.FoundedMonthIsUnknown,
|
||||
SoldDayIsUnknown =
|
||||
c.SoldDayIsUnknown,
|
||||
SoldMonthIsUnknown =
|
||||
c.SoldMonthIsUnknown,
|
||||
FoundedDayIsUnknown = c.FoundedDayIsUnknown,
|
||||
FoundedMonthIsUnknown = c.FoundedMonthIsUnknown,
|
||||
SoldDayIsUnknown = c.SoldDayIsUnknown,
|
||||
SoldMonthIsUnknown = c.SoldMonthIsUnknown,
|
||||
LegalName = c.LegalName
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
@@ -128,6 +117,7 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
||||
public async Task UpdateAsync(CompanyDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Company model = await context.Companies.FindAsync(dto.Id);
|
||||
|
||||
@@ -161,7 +151,9 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
||||
public async Task<int> CreateAsync(CompanyDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new Company
|
||||
{
|
||||
Name = dto.Name,
|
||||
@@ -194,7 +186,7 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<Machine>> GetMachinesAsync(int id) => await context.Machines.Where(m => m.CompanyId == id)
|
||||
public Task<List<Machine>> GetMachinesAsync(int id) => context.Machines.Where(m => m.CompanyId == id)
|
||||
.OrderBy(m => m.Name)
|
||||
.Select(m => new Machine
|
||||
{
|
||||
@@ -219,7 +211,7 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<Company> GetSoldToAsync(int? id) => await context.Companies.Select(c => new Company
|
||||
public Task<Company> GetSoldToAsync(int? id) => context.Companies.Select(c => new Company
|
||||
{
|
||||
Id = c.Id,
|
||||
Name = c.Name
|
||||
@@ -237,8 +229,7 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public Task<List<CompanyDto>> GetCompaniesByCountryAsync(int countryId) => context.Companies
|
||||
.Include(c => c.Logos)
|
||||
public Task<List<CompanyDto>> GetCompaniesByCountryAsync(int countryId) => context.Companies.Include(c => c.Logos)
|
||||
.Where(c => c.CountryId == countryId)
|
||||
.OrderBy(c => c.Name)
|
||||
.Select(c => new CompanyDto
|
||||
@@ -271,6 +262,7 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Company item = await context.Companies.FindAsync(id);
|
||||
|
||||
@@ -285,7 +277,7 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<CompanyDescriptionDto> GetDescriptionAsync(int id) => await context.CompanyDescriptions
|
||||
public Task<CompanyDescriptionDto> GetDescriptionAsync(int id) => context.CompanyDescriptions
|
||||
.Where(d => d.CompanyId == id)
|
||||
.Select(d => new CompanyDescriptionDto
|
||||
{
|
||||
@@ -303,6 +295,7 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
||||
public async Task<int> CreateOrUpdateDescriptionAsync(int id, CompanyDescriptionDto description)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
CompanyDescription current = await context.CompanyDescriptions.FirstOrDefaultAsync(d => d.CompanyId == id);
|
||||
|
||||
|
||||
@@ -23,10 +23,7 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Marechai.Data.Dtos;
|
||||
using Marechai.Database.Models;
|
||||
@@ -34,7 +31,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -73,9 +69,10 @@ public class ComputersController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<MachineDto>> GetComputersByLetterAsync(char c) => await context.Machines
|
||||
.Include(m => m.Company)
|
||||
.Where(m => m.Type == MachineType.Computer && EF.Functions.Like(m.Name, $"{c}%"))
|
||||
public Task<List<MachineDto>> GetComputersByLetterAsync(char c) => context.Machines.Include(m => m.Company)
|
||||
.Where(m =>
|
||||
m.Type == MachineType.Computer &&
|
||||
EF.Functions.Like(m.Name, $"{c}%"))
|
||||
.OrderBy(m => m.Company.Name)
|
||||
.ThenBy(m => m.Name)
|
||||
.Select(m => new MachineDto
|
||||
@@ -90,9 +87,11 @@ public class ComputersController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<MachineDto>> GetComputersByYearAsync(int year) => await context.Machines
|
||||
.Include(m => m.Company)
|
||||
.Where(m => m.Type == MachineType.Computer && m.Introduced != null && m.Introduced.Value.Year == year)
|
||||
public Task<List<MachineDto>> GetComputersByYearAsync(int year) => context.Machines.Include(m => m.Company)
|
||||
.Where(m =>
|
||||
m.Type == MachineType.Computer &&
|
||||
m.Introduced != null &&
|
||||
m.Introduced.Value.Year == year)
|
||||
.OrderBy(m => m.Company.Name)
|
||||
.ThenBy(m => m.Name)
|
||||
.Select(m => new MachineDto
|
||||
@@ -107,7 +106,7 @@ public class ComputersController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<MachineDto>> GetComputersAsync() => await context.Machines.Include(m => m.Company)
|
||||
public Task<List<MachineDto>> GetComputersAsync() => context.Machines.Include(m => m.Company)
|
||||
.Where(m => m.Type == MachineType.Computer)
|
||||
.OrderBy(m => m.Company.Name)
|
||||
.ThenBy(m => m.Name)
|
||||
|
||||
@@ -23,10 +23,7 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Marechai.Data.Dtos;
|
||||
using Marechai.Database.Models;
|
||||
@@ -34,7 +31,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -73,9 +69,10 @@ public class ConsolesController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<MachineDto>> GetConsolesByLetterAsync(char c) => await context.Machines
|
||||
.Include(m => m.Company)
|
||||
.Where(m => m.Type == MachineType.Console && EF.Functions.Like(m.Name, $"{c}%"))
|
||||
public Task<List<MachineDto>> GetConsolesByLetterAsync(char c) => context.Machines.Include(m => m.Company)
|
||||
.Where(m =>
|
||||
m.Type == MachineType.Console &&
|
||||
EF.Functions.Like(m.Name, $"{c}%"))
|
||||
.OrderBy(m => m.Company.Name)
|
||||
.ThenBy(m => m.Name)
|
||||
.Select(m => new MachineDto
|
||||
@@ -90,9 +87,11 @@ public class ConsolesController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<MachineDto>> GetConsolesByYearAsync(int year) => await context.Machines
|
||||
.Include(m => m.Company)
|
||||
.Where(m => m.Type == MachineType.Console && m.Introduced != null && m.Introduced.Value.Year == year)
|
||||
public Task<List<MachineDto>> GetConsolesByYearAsync(int year) => context.Machines.Include(m => m.Company)
|
||||
.Where(m =>
|
||||
m.Type == MachineType.Console &&
|
||||
m.Introduced != null &&
|
||||
m.Introduced.Value.Year == year)
|
||||
.OrderBy(m => m.Company.Name)
|
||||
.ThenBy(m => m.Name)
|
||||
.Select(m => new MachineDto
|
||||
@@ -107,7 +106,7 @@ public class ConsolesController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<MachineDto>> GetConsolesAsync() => await context.Machines.Include(m => m.Company)
|
||||
public Task<List<MachineDto>> GetConsolesAsync() => context.Machines.Include(m => m.Company)
|
||||
.Where(m => m.Type == MachineType.Console)
|
||||
.OrderBy(m => m.Company.Name)
|
||||
.ThenBy(m => m.Name)
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,8 +44,7 @@ public class CurrencyInflationController(MarechaiContext context) : ControllerBa
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<CurrencyInflationDto>> GetAsync() => await context.CurrenciesInflation
|
||||
.OrderBy(i => i.Currency.Name)
|
||||
public Task<List<CurrencyInflationDto>> GetAsync() => context.CurrenciesInflation.OrderBy(i => i.Currency.Name)
|
||||
.ThenBy(i => i.Year)
|
||||
.Select(i => new CurrencyInflationDto
|
||||
{
|
||||
@@ -63,8 +60,7 @@ public class CurrencyInflationController(MarechaiContext context) : ControllerBa
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<CurrencyInflationDto> GetAsync(int id) => await context.CurrenciesInflation
|
||||
.Where(b => b.Id == id)
|
||||
public Task<CurrencyInflationDto> GetAsync(int id) => context.CurrenciesInflation.Where(b => b.Id == id)
|
||||
.Select(i => new CurrencyInflationDto
|
||||
{
|
||||
Id = i.Id,
|
||||
@@ -82,6 +78,7 @@ public class CurrencyInflationController(MarechaiContext context) : ControllerBa
|
||||
public async Task UpdateAsync(CurrencyInflationDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
CurrencyInflation model = await context.CurrenciesInflation.FindAsync(dto.Id);
|
||||
|
||||
@@ -100,7 +97,9 @@ public class CurrencyInflationController(MarechaiContext context) : ControllerBa
|
||||
public async Task<int> CreateAsync(CurrencyInflationDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new CurrencyInflation
|
||||
{
|
||||
CurrencyCode = dto.CurrencyCode,
|
||||
@@ -121,6 +120,7 @@ public class CurrencyInflationController(MarechaiContext context) : ControllerBa
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
CurrencyInflation item = await context.CurrenciesInflation.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,8 +44,7 @@ public class CurrencyPeggingController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<CurrencyPeggingDto>> GetAsync() => await context.CurrenciesPegging
|
||||
.OrderBy(i => i.Source.Name)
|
||||
public Task<List<CurrencyPeggingDto>> GetAsync() => context.CurrenciesPegging.OrderBy(i => i.Source.Name)
|
||||
.ThenBy(i => i.Destination.Name)
|
||||
.ThenBy(i => i.Start)
|
||||
.ThenBy(i => i.End)
|
||||
@@ -68,8 +65,7 @@ public class CurrencyPeggingController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<CurrencyPeggingDto> GetAsync(int id) => await context.CurrenciesPegging
|
||||
.Where(b => b.Id == id)
|
||||
public Task<CurrencyPeggingDto> GetAsync(int id) => context.CurrenciesPegging.Where(b => b.Id == id)
|
||||
.Select(i => new CurrencyPeggingDto
|
||||
{
|
||||
Id = i.Id,
|
||||
@@ -90,6 +86,7 @@ public class CurrencyPeggingController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(CurrencyPeggingDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
CurrencyPegging model = await context.CurrenciesPegging.FindAsync(dto.Id);
|
||||
|
||||
@@ -110,7 +107,9 @@ public class CurrencyPeggingController(MarechaiContext context) : ControllerBase
|
||||
public async Task<int> CreateAsync(CurrencyPeggingDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new CurrencyPegging
|
||||
{
|
||||
SourceCode = dto.SourceCode,
|
||||
@@ -133,6 +132,7 @@ public class CurrencyPeggingController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
CurrencyPegging item = await context.CurrenciesPegging.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,8 +44,7 @@ public class DocumentCompaniesController(MarechaiContext context) : ControllerBa
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<DocumentCompanyDto>> GetAsync() => await context.DocumentCompanies
|
||||
.OrderBy(c => c.Name)
|
||||
public Task<List<DocumentCompanyDto>> GetAsync() => context.DocumentCompanies.OrderBy(c => c.Name)
|
||||
.Select(d => new DocumentCompanyDto
|
||||
{
|
||||
Id = d.Id,
|
||||
@@ -61,8 +58,7 @@ public class DocumentCompaniesController(MarechaiContext context) : ControllerBa
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<DocumentCompanyDto> GetAsync(int id) => await context.DocumentCompanies
|
||||
.Where(d => d.Id == id)
|
||||
public Task<DocumentCompanyDto> GetAsync(int id) => context.DocumentCompanies.Where(d => d.Id == id)
|
||||
.Select(d => new DocumentCompanyDto
|
||||
{
|
||||
Id = d.Id,
|
||||
@@ -78,6 +74,7 @@ public class DocumentCompaniesController(MarechaiContext context) : ControllerBa
|
||||
public async Task UpdateAsync(DocumentCompanyDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
DocumentCompany model = await context.DocumentCompanies.FindAsync(dto.Id);
|
||||
|
||||
@@ -96,7 +93,9 @@ public class DocumentCompaniesController(MarechaiContext context) : ControllerBa
|
||||
public async Task<int> CreateAsync(DocumentCompanyDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new DocumentCompany
|
||||
{
|
||||
CompanyId = dto.CompanyId,
|
||||
@@ -116,6 +115,7 @@ public class DocumentCompaniesController(MarechaiContext context) : ControllerBa
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
DocumentCompany item = await context.DocumentCompanies.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,8 +44,7 @@ public class DocumentPeopleController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<DocumentPersonDto>> GetAsync() => await context.DocumentPeople
|
||||
.OrderBy(d => d.DisplayName)
|
||||
public Task<List<DocumentPersonDto>> GetAsync() => context.DocumentPeople.OrderBy(d => d.DisplayName)
|
||||
.ThenBy(d => d.Alias)
|
||||
.ThenBy(d => d.Name)
|
||||
.ThenBy(d => d.Surname)
|
||||
@@ -64,7 +61,7 @@ public class DocumentPeopleController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<DocumentPersonDto> GetAsync(int id) => await context.DocumentPeople.Where(p => p.Id == id)
|
||||
public Task<DocumentPersonDto> GetAsync(int id) => context.DocumentPeople.Where(p => p.Id == id)
|
||||
.Select(d => new DocumentPersonDto
|
||||
{
|
||||
Id = d.Id,
|
||||
@@ -83,6 +80,7 @@ public class DocumentPeopleController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(DocumentPersonDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
DocumentPerson model = await context.DocumentPeople.FindAsync(dto.Id);
|
||||
|
||||
@@ -104,7 +102,9 @@ public class DocumentPeopleController(MarechaiContext context) : ControllerBase
|
||||
public async Task<int> CreateAsync(DocumentPersonDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new DocumentPerson
|
||||
{
|
||||
Alias = dto.Alias,
|
||||
@@ -127,6 +127,7 @@ public class DocumentPeopleController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
DocumentPerson item = await context.DocumentPeople.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,10 +23,8 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Marechai.Data.Dtos;
|
||||
using Marechai.Database.Models;
|
||||
@@ -34,7 +32,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +43,7 @@ public class DocumentRolesController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<DocumentRoleDto>> GetAsync() => await context.DocumentRoles.OrderBy(c => c.Name)
|
||||
public Task<List<DocumentRoleDto>> GetAsync() => context.DocumentRoles.OrderBy(c => c.Name)
|
||||
.Select(c => new DocumentRoleDto
|
||||
{
|
||||
Id = c.Id,
|
||||
@@ -59,8 +56,7 @@ public class DocumentRolesController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<DocumentRoleDto>> GetEnabledAsync() => await context.DocumentRoles
|
||||
.Where(c => c.Enabled)
|
||||
public Task<List<DocumentRoleDto>> GetEnabledAsync() => context.DocumentRoles.Where(c => c.Enabled)
|
||||
.OrderBy(c => c.Name)
|
||||
.Select(c => new DocumentRoleDto
|
||||
{
|
||||
@@ -74,7 +70,7 @@ public class DocumentRolesController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<DocumentRoleDto> GetAsync(string id) => await context.DocumentRoles.Where(c => c.Id == id)
|
||||
public Task<DocumentRoleDto> GetAsync(string id) => context.DocumentRoles.Where(c => c.Id == id)
|
||||
.Select(c => new DocumentRoleDto
|
||||
{
|
||||
Id = c.Id,
|
||||
|
||||
@@ -34,7 +34,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -53,7 +52,7 @@ public class DocumentScansController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<DocumentScanDto> GetAsync(Guid id) => await context.DocumentScans.Where(p => p.Id == id)
|
||||
public Task<DocumentScanDto> GetAsync(Guid id) => context.DocumentScans.Where(p => p.Id == id)
|
||||
.Select(p => new DocumentScanDto
|
||||
{
|
||||
Author = p.Author,
|
||||
@@ -84,6 +83,7 @@ public class DocumentScansController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(DocumentScanDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
DocumentScan model = await context.DocumentScans.FindAsync(dto.Id);
|
||||
|
||||
@@ -113,7 +113,9 @@ public class DocumentScansController(MarechaiContext context) : ControllerBase
|
||||
public async Task<Guid> CreateAsync(DocumentScanDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return null;
|
||||
|
||||
var model = new DocumentScan
|
||||
{
|
||||
Author = dto.Author,
|
||||
@@ -149,6 +151,7 @@ public class DocumentScansController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(Guid id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
DocumentScan item = await context.DocumentScans.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class DocumentsByMachineController(MarechaiContext context) : ControllerB
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<DocumentByMachineDto>> GetByDocument(long bookId) => await context.DocumentsByMachines
|
||||
public Task<List<DocumentByMachineDto>> GetByDocument(long bookId) => context.DocumentsByMachines
|
||||
.Where(p => p.DocumentId == bookId)
|
||||
.Select(p => new DocumentByMachineDto
|
||||
{
|
||||
@@ -65,6 +63,7 @@ public class DocumentsByMachineController(MarechaiContext context) : ControllerB
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
DocumentsByMachine item = await context.DocumentsByMachines.FindAsync(id);
|
||||
|
||||
@@ -82,7 +81,9 @@ public class DocumentsByMachineController(MarechaiContext context) : ControllerB
|
||||
public async Task<long> CreateAsync(int machineId, long bookId)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var item = new DocumentsByMachine
|
||||
{
|
||||
MachineId = machineId,
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,8 +44,8 @@ public class DocumentsByMachineFamilyController(MarechaiContext context) : Contr
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<DocumentByMachineFamilyDto>> GetByDocument(long bookId) => await context
|
||||
.DocumentsByMachineFamilies.Where(p => p.DocumentId == bookId)
|
||||
public Task<List<DocumentByMachineFamilyDto>> GetByDocument(long bookId) => context.DocumentsByMachineFamilies
|
||||
.Where(p => p.DocumentId == bookId)
|
||||
.Select(p => new DocumentByMachineFamilyDto
|
||||
{
|
||||
Id = p.Id,
|
||||
@@ -65,6 +63,7 @@ public class DocumentsByMachineFamilyController(MarechaiContext context) : Contr
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
DocumentsByMachineFamily item = await context.DocumentsByMachineFamilies.FindAsync(id);
|
||||
|
||||
@@ -82,7 +81,9 @@ public class DocumentsByMachineFamilyController(MarechaiContext context) : Contr
|
||||
public async Task<long> CreateAsync(int machineFamilyId, long bookId)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var item = new DocumentsByMachineFamily
|
||||
{
|
||||
MachineFamilyId = machineFamilyId,
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class DocumentsController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<DocumentDto>> GetAsync() => await context.Documents.OrderBy(b => b.NativeTitle)
|
||||
public Task<List<DocumentDto>> GetAsync() => context.Documents.OrderBy(b => b.NativeTitle)
|
||||
.ThenBy(b => b.Published)
|
||||
.ThenBy(b => b.Title)
|
||||
.Select(b => new DocumentDto
|
||||
@@ -65,7 +63,7 @@ public class DocumentsController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<DocumentDto> GetAsync(long id) => await context.Documents.Where(b => b.Id == id)
|
||||
public Task<DocumentDto> GetAsync(long id) => context.Documents.Where(b => b.Id == id)
|
||||
.Select(b => new DocumentDto
|
||||
{
|
||||
Id = b.Id,
|
||||
@@ -85,6 +83,7 @@ public class DocumentsController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(DocumentDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Document model = await context.Documents.FindAsync(dto.Id);
|
||||
|
||||
@@ -105,7 +104,9 @@ public class DocumentsController(MarechaiContext context) : ControllerBase
|
||||
public async Task<long> CreateAsync(DocumentDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new Document
|
||||
{
|
||||
Title = dto.Title,
|
||||
@@ -135,6 +136,7 @@ public class DocumentsController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Document item = await context.Documents.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class DumpsController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<DumpDto>> GetAsync() => await context.Dumps.OrderBy(d => d.Dumper)
|
||||
public Task<List<DumpDto>> GetAsync() => context.Dumps.OrderBy(d => d.Dumper)
|
||||
.ThenBy(d => d.DumpingGroup)
|
||||
.ThenBy(b => b.Media.Title)
|
||||
.ThenBy(d => d.DumpDate)
|
||||
@@ -68,7 +66,7 @@ public class DumpsController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<DumpDto> GetAsync(ulong id) => await context.Dumps.Where(d => d.Id == id)
|
||||
public Task<DumpDto> GetAsync(ulong id) => context.Dumps.Where(d => d.Id == id)
|
||||
.Select(d => new DumpDto
|
||||
{
|
||||
Id = d.Id,
|
||||
@@ -90,6 +88,7 @@ public class DumpsController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(DumpDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Dump model = await context.Dumps.FindAsync(dto.Id);
|
||||
|
||||
@@ -111,7 +110,9 @@ public class DumpsController(MarechaiContext context) : ControllerBase
|
||||
public async Task<ulong> CreateAsync(DumpDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return null;
|
||||
|
||||
var model = new Dump
|
||||
{
|
||||
Dumper = dto.Dumper,
|
||||
@@ -135,6 +136,7 @@ public class DumpsController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(ulong id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Dump item = await context.Dumps.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class GpusByMachineController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<GpuByMachineDto>> GetByMachine(int machineId) => await context.GpusByMachine
|
||||
public Task<List<GpuByMachineDto>> GetByMachine(int machineId) => context.GpusByMachine
|
||||
.Where(g => g.MachineId == machineId)
|
||||
.Select(g => new GpuByMachineDto
|
||||
{
|
||||
@@ -67,6 +65,7 @@ public class GpusByMachineController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
GpusByMachine item = await context.GpusByMachine.FindAsync(id);
|
||||
|
||||
@@ -84,7 +83,9 @@ public class GpusByMachineController(MarechaiContext context) : ControllerBase
|
||||
public async Task<long> CreateAsync(int gpuId, int machineId)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var item = new GpusByMachine
|
||||
{
|
||||
GpuId = gpuId,
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class GpusController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<GpuDto>> GetAsync() => await context.Gpus.OrderBy(g => g.Company.Name)
|
||||
public Task<List<GpuDto>> GetAsync() => context.Gpus.OrderBy(g => g.Company.Name)
|
||||
.ThenBy(g => g.Name)
|
||||
.ThenBy(g => g.Introduced)
|
||||
.Select(g => new GpuDto
|
||||
@@ -63,7 +61,7 @@ public class GpusController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<GpuDto>> GetByMachineAsync(int machineId) => await context.GpusByMachine
|
||||
public Task<List<GpuDto>> GetByMachineAsync(int machineId) => context.GpusByMachine
|
||||
.Where(g => g.MachineId == machineId)
|
||||
.Select(g => g.Gpu)
|
||||
.OrderBy(g => g.Company.Name)
|
||||
@@ -88,7 +86,7 @@ public class GpusController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<GpuDto> GetAsync(int id) => await context.Gpus.Where(g => g.Id == id)
|
||||
public Task<GpuDto> GetAsync(int id) => context.Gpus.Where(g => g.Id == id)
|
||||
.Select(g => new GpuDto
|
||||
{
|
||||
Id = g.Id,
|
||||
@@ -111,6 +109,7 @@ public class GpusController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(GpuDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Gpu model = await context.Gpus.FindAsync(dto.Id);
|
||||
|
||||
@@ -136,7 +135,9 @@ public class GpusController(MarechaiContext context) : ControllerBase
|
||||
public async Task<int> CreateAsync(GpuDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new Gpu
|
||||
{
|
||||
Name = dto.Name,
|
||||
@@ -163,6 +164,7 @@ public class GpusController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Gpu item = await context.Gpus.FindAsync(id);
|
||||
|
||||
|
||||
@@ -28,13 +28,11 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Marechai.Data.Dtos;
|
||||
using Marechai.Database.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,8 +44,7 @@ public class InstructionSetExtensionsController(MarechaiContext context) : Contr
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<InstructionSetExtension>> GetAsync() => await context.InstructionSetExtensions
|
||||
.OrderBy(e => e.Extension)
|
||||
public Task<List<InstructionSetExtension>> GetAsync() => context.InstructionSetExtensions.OrderBy(e => e.Extension)
|
||||
.Select(e => new InstructionSetExtension
|
||||
{
|
||||
Extension = e.Extension,
|
||||
@@ -59,8 +56,7 @@ public class InstructionSetExtensionsController(MarechaiContext context) : Contr
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<InstructionSetExtension> GetAsync(int id) => await context.InstructionSetExtensions
|
||||
.Where(e => e.Id == id)
|
||||
public Task<InstructionSetExtension> GetAsync(int id) => context.InstructionSetExtensions.Where(e => e.Id == id)
|
||||
.Select(e => new InstructionSetExtension
|
||||
{
|
||||
Extension = e.Extension,
|
||||
@@ -75,6 +71,7 @@ public class InstructionSetExtensionsController(MarechaiContext context) : Contr
|
||||
public async Task UpdateAsync(InstructionSetExtension viewModel)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
InstructionSetExtension model = await context.InstructionSetExtensions.FindAsync(viewModel.Id);
|
||||
|
||||
@@ -92,7 +89,9 @@ public class InstructionSetExtensionsController(MarechaiContext context) : Contr
|
||||
public async Task<int> CreateAsync(InstructionSetExtension viewModel)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new InstructionSetExtension
|
||||
{
|
||||
Extension = viewModel.Extension
|
||||
@@ -111,6 +110,7 @@ public class InstructionSetExtensionsController(MarechaiContext context) : Contr
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
InstructionSetExtension item = await context.InstructionSetExtensions.FindAsync(id);
|
||||
|
||||
|
||||
@@ -28,13 +28,11 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Marechai.Data.Dtos;
|
||||
using Marechai.Database.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class InstructionSetsController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<InstructionSet>> GetAsync() => await context.InstructionSets.OrderBy(e => e.Name)
|
||||
public Task<List<InstructionSet>> GetAsync() => context.InstructionSets.OrderBy(e => e.Name)
|
||||
.Select(e => new InstructionSet
|
||||
{
|
||||
Name = e.Name,
|
||||
@@ -58,7 +56,7 @@ public class InstructionSetsController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<InstructionSet> GetAsync(int id) => await context.InstructionSets.Where(e => e.Id == id)
|
||||
public Task<InstructionSet> GetAsync(int id) => context.InstructionSets.Where(e => e.Id == id)
|
||||
.Select(e => new InstructionSet
|
||||
{
|
||||
Name = e.Name,
|
||||
@@ -73,6 +71,7 @@ public class InstructionSetsController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(InstructionSet viewModel)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
InstructionSet model = await context.InstructionSets.FindAsync(viewModel.Id);
|
||||
|
||||
@@ -90,7 +89,9 @@ public class InstructionSetsController(MarechaiContext context) : ControllerBase
|
||||
public async Task<int> CreateAsync(InstructionSet viewModel)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new InstructionSet
|
||||
{
|
||||
Name = viewModel.Name
|
||||
@@ -109,6 +110,7 @@ public class InstructionSetsController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
InstructionSet item = await context.InstructionSets.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,18 +23,14 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Marechai.Data.Dtos;
|
||||
using Marechai.Database.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,5 +42,5 @@ public class Iso4217Controller(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<Iso4217>> GetAsync() => await context.Iso4217.OrderBy(c => c.Name).ToListAsync();
|
||||
public Task<List<Iso4217>> GetAsync() => context.Iso4217.OrderBy(c => c.Name).ToListAsync();
|
||||
}
|
||||
@@ -23,18 +23,15 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Marechai.Data.Dtos;
|
||||
using Marechai.Database.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +43,7 @@ public class LicensesController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<License>> GetAsync() => await context.Licenses.OrderBy(l => l.Name)
|
||||
public Task<List<License>> GetAsync() => context.Licenses.OrderBy(l => l.Name)
|
||||
.Select(l => new License
|
||||
{
|
||||
FsfApproved = l.FsfApproved,
|
||||
@@ -62,7 +59,7 @@ public class LicensesController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<License> GetAsync(int id) => await context.Licenses.Where(l => l.Id == id)
|
||||
public Task<License> GetAsync(int id) => context.Licenses.Where(l => l.Id == id)
|
||||
.Select(l => new License
|
||||
{
|
||||
FsfApproved = l.FsfApproved,
|
||||
@@ -82,6 +79,7 @@ public class LicensesController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(License viewModel)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
License model = await context.Licenses.FindAsync(viewModel.Id);
|
||||
|
||||
@@ -104,7 +102,9 @@ public class LicensesController(MarechaiContext context) : ControllerBase
|
||||
public async Task<int> CreateAsync(License viewModel)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new License
|
||||
{
|
||||
FsfApproved = viewModel.FsfApproved,
|
||||
@@ -128,6 +128,7 @@ public class LicensesController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
License item = await context.Licenses.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,8 +44,7 @@ public class MachineFamiliesController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<MachineFamilyDto>> GetAsync() => await context.MachineFamilies
|
||||
.OrderBy(m => m.Company.Name)
|
||||
public Task<List<MachineFamilyDto>> GetAsync() => context.MachineFamilies.OrderBy(m => m.Company.Name)
|
||||
.ThenBy(m => m.Name)
|
||||
.Select(m => new MachineFamilyDto
|
||||
{
|
||||
@@ -62,7 +59,7 @@ public class MachineFamiliesController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<MachineFamilyDto> GetAsync(int id) => await context.MachineFamilies.Where(f => f.Id == id)
|
||||
public Task<MachineFamilyDto> GetAsync(int id) => context.MachineFamilies.Where(f => f.Id == id)
|
||||
.Select(m => new MachineFamilyDto
|
||||
{
|
||||
Id = m.Id,
|
||||
@@ -78,6 +75,7 @@ public class MachineFamiliesController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(MachineFamilyDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
MachineFamily model = await context.MachineFamilies.FindAsync(dto.Id);
|
||||
|
||||
@@ -96,7 +94,9 @@ public class MachineFamiliesController(MarechaiContext context) : ControllerBase
|
||||
public async Task<int> CreateAsync(MachineFamilyDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new MachineFamily
|
||||
{
|
||||
Name = dto.Name,
|
||||
@@ -116,6 +116,7 @@ public class MachineFamiliesController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
MachineFamily item = await context.MachineFamilies.FindAsync(id);
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -53,7 +52,7 @@ public class MachinePhotosController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<MachinePhotoDto> GetAsync(Guid id) => await context.MachinePhotos.Where(p => p.Id == id)
|
||||
public Task<MachinePhotoDto> GetAsync(Guid id) => context.MachinePhotos.Where(p => p.Id == id)
|
||||
.Select(p => new MachinePhotoDto
|
||||
{
|
||||
Aperture = p.Aperture,
|
||||
@@ -72,18 +71,15 @@ public class MachinePhotosController(MarechaiContext context) : ControllerBase
|
||||
Flash = p.Flash,
|
||||
Focal = p.Focal,
|
||||
FocalLength = p.FocalLength,
|
||||
FocalLengthEquivalent =
|
||||
p.FocalLengthEquivalent,
|
||||
HorizontalResolution =
|
||||
p.HorizontalResolution,
|
||||
FocalLengthEquivalent = p.FocalLengthEquivalent,
|
||||
HorizontalResolution = p.HorizontalResolution,
|
||||
Id = p.Id,
|
||||
IsoRating = p.IsoRating,
|
||||
Lens = p.Lens,
|
||||
LicenseId = p.LicenseId,
|
||||
LicenseName = p.License.Name,
|
||||
LightSource = p.LightSource,
|
||||
MachineCompanyName =
|
||||
p.Machine.Company.Name,
|
||||
MachineCompanyName = p.Machine.Company.Name,
|
||||
MachineId = p.MachineId,
|
||||
MachineName = p.Machine.Name,
|
||||
MeteringMode = p.MeteringMode,
|
||||
@@ -95,8 +91,7 @@ public class MachinePhotosController(MarechaiContext context) : ControllerBase
|
||||
Sharpness = p.Sharpness,
|
||||
SoftwareUsed = p.SoftwareUsed,
|
||||
Source = p.Source,
|
||||
SubjectDistanceRange =
|
||||
p.SubjectDistanceRange,
|
||||
SubjectDistanceRange = p.SubjectDistanceRange,
|
||||
UploadDate = p.UploadDate,
|
||||
UserId = p.UserId,
|
||||
VerticalResolution = p.VerticalResolution,
|
||||
@@ -112,6 +107,7 @@ public class MachinePhotosController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(MachinePhotoDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
MachinePhoto model = await context.MachinePhotos.FindAsync(dto.Id);
|
||||
|
||||
@@ -162,7 +158,9 @@ public class MachinePhotosController(MarechaiContext context) : ControllerBase
|
||||
public async Task<Guid> CreateAsync(MachinePhotoDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return null;
|
||||
|
||||
var model = new MachinePhoto
|
||||
{
|
||||
Aperture = dto.Aperture,
|
||||
|
||||
@@ -40,17 +40,20 @@ namespace Marechai.Server.Controllers;
|
||||
|
||||
[Route("/machines")]
|
||||
[ApiController]
|
||||
public class MachinesController(MarechaiContext context,
|
||||
public class MachinesController
|
||||
(
|
||||
MarechaiContext context,
|
||||
IStringLocalizer<MachinesService> localizer,
|
||||
GpusService gpusService,
|
||||
ProcessorsService processorsService,
|
||||
SoundSynthsService soundSynthsService) : ControllerBase
|
||||
SoundSynthsService soundSynthsService
|
||||
) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<MachineDto>> GetAsync() => await context.Machines.OrderBy(m => m.Company.Name)
|
||||
public Task<List<MachineDto>> GetAsync() => context.Machines.OrderBy(m => m.Company.Name)
|
||||
.ThenBy(m => m.Name)
|
||||
.ThenBy(m => m.Family.Name)
|
||||
.Select(m => new MachineDto
|
||||
@@ -69,7 +72,7 @@ public class MachinesController(MarechaiContext context,
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<MachineDto> GetAsync(int id) => await context.Machines.Where(m => m.Id == id)
|
||||
public Task<MachineDto> GetAsync(int id) => context.Machines.Where(m => m.Id == id)
|
||||
.Select(m => new MachineDto
|
||||
{
|
||||
Id = m.Id,
|
||||
@@ -90,6 +93,7 @@ public class MachinesController(MarechaiContext context,
|
||||
public async Task UpdateAsync(MachineDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Machine model = await context.Machines.FindAsync(dto.Id);
|
||||
|
||||
@@ -136,7 +140,9 @@ public class MachinesController(MarechaiContext context,
|
||||
public async Task<int> CreateAsync(MachineDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new Machine
|
||||
{
|
||||
CompanyId = dto.CompanyId,
|
||||
@@ -209,9 +215,7 @@ public class MachinesController(MarechaiContext context,
|
||||
IQueryable<CompanyLogo> logos = context.CompanyLogos.Where(l => l.CompanyId == company.Id);
|
||||
|
||||
if(model.Introduced.HasValue)
|
||||
{
|
||||
model.CompanyLogo = (await logos.FirstOrDefaultAsync(l => l.Year >= model.Introduced.Value.Year))?.Guid;
|
||||
}
|
||||
|
||||
if(model.CompanyLogo is null && logos.Any()) model.CompanyLogo = (await logos.FirstAsync())?.Guid;
|
||||
}
|
||||
@@ -259,6 +263,7 @@ public class MachinesController(MarechaiContext context,
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Machine item = await context.Machines.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,8 +44,7 @@ public class MagazineIssuesController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<MagazineIssueDto>> GetAsync() => await context.MagazineIssues
|
||||
.OrderBy(b => b.Magazine.Title)
|
||||
public Task<List<MagazineIssueDto>> GetAsync() => context.MagazineIssues.OrderBy(b => b.Magazine.Title)
|
||||
.ThenBy(b => b.Published)
|
||||
.ThenBy(b => b.Caption)
|
||||
.Select(b => new MagazineIssueDto
|
||||
@@ -68,7 +65,7 @@ public class MagazineIssuesController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<MagazineIssueDto> GetAsync(long id) => await context.MagazineIssues.Where(b => b.Id == id)
|
||||
public Task<MagazineIssueDto> GetAsync(long id) => context.MagazineIssues.Where(b => b.Id == id)
|
||||
.Select(b => new MagazineIssueDto
|
||||
{
|
||||
Id = b.Id,
|
||||
@@ -90,6 +87,7 @@ public class MagazineIssuesController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(MagazineIssueDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
MagazineIssue model = await context.MagazineIssues.FindAsync(dto.Id);
|
||||
|
||||
@@ -112,7 +110,9 @@ public class MagazineIssuesController(MarechaiContext context) : ControllerBase
|
||||
public async Task<long> CreateAsync(MagazineIssueDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new MagazineIssue
|
||||
{
|
||||
MagazineId = dto.MagazineId,
|
||||
@@ -137,6 +137,7 @@ public class MagazineIssuesController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
MagazineIssue item = await context.MagazineIssues.FindAsync(id);
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -53,7 +52,7 @@ public class MagazineScansController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<MagazineScanDto> GetAsync(Guid id) => await context.MagazineScans.Where(p => p.Id == id)
|
||||
public Task<MagazineScanDto> GetAsync(Guid id) => context.MagazineScans.Where(p => p.Id == id)
|
||||
.Select(p => new MagazineScanDto
|
||||
{
|
||||
Author = p.Author,
|
||||
@@ -84,6 +83,7 @@ public class MagazineScansController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(MagazineScanDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
MagazineScan model = await context.MagazineScans.FindAsync(dto.Id);
|
||||
|
||||
@@ -113,7 +113,9 @@ public class MagazineScansController(MarechaiContext context) : ControllerBase
|
||||
public async Task<Guid> CreateAsync(MagazineScanDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return null;
|
||||
|
||||
var model = new MagazineScan
|
||||
{
|
||||
Author = dto.Author,
|
||||
@@ -149,6 +151,7 @@ public class MagazineScansController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(Guid id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
MagazineScan item = await context.MagazineScans.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class MagazinesByMachineController(MarechaiContext context) : ControllerB
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<MagazineByMachineDto>> GetByMagazine(long bookId) => await context.MagazinesByMachines
|
||||
public Task<List<MagazineByMachineDto>> GetByMagazine(long bookId) => context.MagazinesByMachines
|
||||
.Where(p => p.MagazineId == bookId)
|
||||
.Select(p => new MagazineByMachineDto
|
||||
{
|
||||
@@ -65,6 +63,7 @@ public class MagazinesByMachineController(MarechaiContext context) : ControllerB
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
MagazinesByMachine item = await context.MagazinesByMachines.FindAsync(id);
|
||||
|
||||
@@ -82,7 +81,9 @@ public class MagazinesByMachineController(MarechaiContext context) : ControllerB
|
||||
public async Task<long> CreateAsync(int machineId, long bookId)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var item = new MagazinesByMachine
|
||||
{
|
||||
MachineId = machineId,
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,8 +44,8 @@ public class MagazinesByMachineFamilyController(MarechaiContext context) : Contr
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<MagazineByMachineFamilyDto>> GetByMagazine(long bookId) => await context
|
||||
.MagazinesByMachinesFamilies.Where(p => p.MagazineId == bookId)
|
||||
public Task<List<MagazineByMachineFamilyDto>> GetByMagazine(long bookId) => context.MagazinesByMachinesFamilies
|
||||
.Where(p => p.MagazineId == bookId)
|
||||
.Select(p => new MagazineByMachineFamilyDto
|
||||
{
|
||||
Id = p.Id,
|
||||
@@ -65,6 +63,7 @@ public class MagazinesByMachineFamilyController(MarechaiContext context) : Contr
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
MagazinesByMachineFamily item = await context.MagazinesByMachinesFamilies.FindAsync(id);
|
||||
|
||||
@@ -82,7 +81,9 @@ public class MagazinesByMachineFamilyController(MarechaiContext context) : Contr
|
||||
public async Task<long> CreateAsync(int machineFamilyId, long bookId)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var item = new MagazinesByMachineFamily
|
||||
{
|
||||
MachineFamilyId = machineFamilyId,
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class MagazinesController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<MagazineDto>> GetAsync() => await context.Magazines.OrderBy(b => b.NativeTitle)
|
||||
public Task<List<MagazineDto>> GetAsync() => context.Magazines.OrderBy(b => b.NativeTitle)
|
||||
.ThenBy(b => b.FirstPublication)
|
||||
.ThenBy(b => b.Title)
|
||||
.Select(b => new MagazineDto
|
||||
@@ -66,7 +64,7 @@ public class MagazinesController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<MagazineDto>> GetTitlesAsync() => await context.Magazines.OrderBy(b => b.Title)
|
||||
public Task<List<MagazineDto>> GetTitlesAsync() => context.Magazines.OrderBy(b => b.Title)
|
||||
.ThenBy(b => b.FirstPublication)
|
||||
.Select(b => new MagazineDto
|
||||
{
|
||||
@@ -79,7 +77,7 @@ public class MagazinesController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<MagazineDto> GetAsync(long id) => await context.Magazines.Where(b => b.Id == id)
|
||||
public Task<MagazineDto> GetAsync(long id) => context.Magazines.Where(b => b.Id == id)
|
||||
.Select(b => new MagazineDto
|
||||
{
|
||||
Id = b.Id,
|
||||
@@ -100,6 +98,7 @@ public class MagazinesController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(MagazineDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Magazine model = await context.Magazines.FindAsync(dto.Id);
|
||||
|
||||
@@ -121,7 +120,9 @@ public class MagazinesController(MarechaiContext context) : ControllerBase
|
||||
public async Task<long> CreateAsync(MagazineDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new Magazine
|
||||
{
|
||||
Title = dto.Title,
|
||||
@@ -152,6 +153,7 @@ public class MagazinesController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Magazine item = await context.Magazines.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class MediaController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<MediaDto>> GetAsync() => await context.Media.OrderBy(d => d.Title)
|
||||
public Task<List<MediaDto>> GetAsync() => context.Media.OrderBy(d => d.Title)
|
||||
.Select(d => new MediaDto
|
||||
{
|
||||
Id = d.Id,
|
||||
@@ -82,7 +80,7 @@ public class MediaController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<MediaDto>> GetTitlesAsync() => await context.Media.OrderBy(d => d.Title)
|
||||
public Task<List<MediaDto>> GetTitlesAsync() => context.Media.OrderBy(d => d.Title)
|
||||
.Select(d => new MediaDto
|
||||
{
|
||||
Id = d.Id,
|
||||
@@ -94,7 +92,7 @@ public class MediaController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<MediaDto> GetAsync(ulong id) => await context.Media.Where(d => d.Id == id)
|
||||
public Task<MediaDto> GetAsync(ulong id) => context.Media.Where(d => d.Id == id)
|
||||
.Select(d => new MediaDto
|
||||
{
|
||||
Id = d.Id,
|
||||
@@ -133,6 +131,7 @@ public class MediaController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(MediaDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Media model = await context.Media.FindAsync(dto.Id);
|
||||
|
||||
@@ -173,7 +172,9 @@ public class MediaController(MarechaiContext context) : ControllerBase
|
||||
public async Task<ulong> CreateAsync(MediaDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return null;
|
||||
|
||||
var model = new Media
|
||||
{
|
||||
Title = dto.Title,
|
||||
@@ -216,6 +217,7 @@ public class MediaController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(ulong id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Media item = await context.Media.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class MemoriesByMachineController(MarechaiContext context) : ControllerBa
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<MemoryByMachineDto>> GetByMachine(int machineId) => await context.MemoryByMachine
|
||||
public Task<List<MemoryByMachineDto>> GetByMachine(int machineId) => context.MemoryByMachine
|
||||
.Where(m => m.MachineId == machineId)
|
||||
.Select(m => new MemoryByMachineDto
|
||||
{
|
||||
@@ -70,6 +68,7 @@ public class MemoriesByMachineController(MarechaiContext context) : ControllerBa
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
MemoryByMachine item = await context.MemoryByMachine.FindAsync(id);
|
||||
|
||||
@@ -87,7 +86,9 @@ public class MemoriesByMachineController(MarechaiContext context) : ControllerBa
|
||||
public async Task<long> CreateAsync(int machineId, MemoryType type, MemoryUsage usage, long? size, double? speed)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var item = new MemoryByMachine
|
||||
{
|
||||
MachineId = machineId,
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -46,7 +45,7 @@ public class NewsController(MarechaiContext context, IStringLocalizer<NewsServic
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<NewsDto>> GetAsync() => await context.News.OrderByDescending(n => n.Date)
|
||||
public Task<List<NewsDto>> GetAsync() => context.News.OrderByDescending(n => n.Date)
|
||||
.Select(n => new NewsDto
|
||||
{
|
||||
Id = n.Id,
|
||||
@@ -162,6 +161,7 @@ public class NewsController(MarechaiContext context, IStringLocalizer<NewsServic
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
News item = await context.News.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class PeopleController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<PersonDto>> GetAsync() => await context.People.OrderBy(p => p.DisplayName)
|
||||
public Task<List<PersonDto>> GetAsync() => context.People.OrderBy(p => p.DisplayName)
|
||||
.ThenBy(p => p.Alias)
|
||||
.ThenBy(p => p.Name)
|
||||
.ThenBy(p => p.Surname)
|
||||
@@ -71,7 +69,7 @@ public class PeopleController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<PersonDto> GetAsync(int id) => await context.People.Where(p => p.Id == id)
|
||||
public Task<PersonDto> GetAsync(int id) => context.People.Where(p => p.Id == id)
|
||||
.Select(p => new PersonDto
|
||||
{
|
||||
Id = p.Id,
|
||||
@@ -96,6 +94,7 @@ public class PeopleController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(PersonDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Person model = await context.People.FindAsync(dto.Id);
|
||||
|
||||
@@ -123,7 +122,9 @@ public class PeopleController(MarechaiContext context) : ControllerBase
|
||||
public async Task<int> CreateAsync(PersonDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new Person
|
||||
{
|
||||
Name = dto.Name,
|
||||
@@ -152,6 +153,7 @@ public class PeopleController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Person item = await context.People.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,8 +44,8 @@ public class ProcessorsByMachineController(MarechaiContext context) : Controller
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<ProcessorByMachineDto>> GetByMachine(int machineId) => await context
|
||||
.ProcessorsByMachine.Where(p => p.MachineId == machineId)
|
||||
public Task<List<ProcessorByMachineDto>> GetByMachine(int machineId) => context.ProcessorsByMachine
|
||||
.Where(p => p.MachineId == machineId)
|
||||
.Select(p => new ProcessorByMachineDto
|
||||
{
|
||||
Id = p.Id,
|
||||
@@ -68,6 +66,7 @@ public class ProcessorsByMachineController(MarechaiContext context) : Controller
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
ProcessorsByMachine item = await context.ProcessorsByMachine.FindAsync(id);
|
||||
|
||||
@@ -85,7 +84,9 @@ public class ProcessorsByMachineController(MarechaiContext context) : Controller
|
||||
public async Task<long> CreateAsync(int processorId, int machineId, float? speed)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var item = new ProcessorsByMachine
|
||||
{
|
||||
ProcessorId = processorId,
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,8 +44,7 @@ public class ProcessorsController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<ProcessorDto>> GetAsync() => await context.Processors
|
||||
.Select(p => new ProcessorDto
|
||||
public Task<List<ProcessorDto>> GetAsync() => context.Processors.Select(p => new ProcessorDto
|
||||
{
|
||||
Name = p.Name,
|
||||
CompanyName = p.Company.Name,
|
||||
@@ -76,10 +73,8 @@ public class ProcessorsController(MarechaiContext context) : ControllerBase
|
||||
L3 = p.L3,
|
||||
InstructionSet = p.InstructionSet.Name,
|
||||
Id = p.Id,
|
||||
InstructionSetExtensions =
|
||||
p.InstructionSetExtensions
|
||||
.Select(e => e.Extension
|
||||
.Extension)
|
||||
InstructionSetExtensions = p.InstructionSetExtensions
|
||||
.Select(e => e.Extension.Extension)
|
||||
.ToList()
|
||||
})
|
||||
.OrderBy(p => p.CompanyName)
|
||||
@@ -90,7 +85,7 @@ public class ProcessorsController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<ProcessorDto>> GetByMachineAsync(int machineId) => await context.ProcessorsByMachine
|
||||
public Task<List<ProcessorDto>> GetByMachineAsync(int machineId) => context.ProcessorsByMachine
|
||||
.Where(p => p.MachineId == machineId)
|
||||
.Select(p => new ProcessorDto
|
||||
{
|
||||
@@ -121,8 +116,7 @@ public class ProcessorsController(MarechaiContext context) : ControllerBase
|
||||
L3 = p.Processor.L3,
|
||||
InstructionSet = p.Processor.InstructionSet.Name,
|
||||
Id = p.Processor.Id,
|
||||
InstructionSetExtensions =
|
||||
p.Processor.InstructionSetExtensions.Select(e => e.Extension.Extension).ToList()
|
||||
InstructionSetExtensions = p.Processor.InstructionSetExtensions.Select(e => e.Extension.Extension).ToList()
|
||||
})
|
||||
.OrderBy(p => p.CompanyName)
|
||||
.ThenBy(p => p.Name)
|
||||
@@ -132,7 +126,7 @@ public class ProcessorsController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<ProcessorDto> GetAsync(int id) => await context.Processors.Where(p => p.Id == id)
|
||||
public Task<ProcessorDto> GetAsync(int id) => context.Processors.Where(p => p.Id == id)
|
||||
.Select(p => new ProcessorDto
|
||||
{
|
||||
Name = p.Name,
|
||||
@@ -160,8 +154,7 @@ public class ProcessorsController(MarechaiContext context) : ControllerBase
|
||||
L1Data = p.L1Data,
|
||||
L2 = p.L2,
|
||||
L3 = p.L3,
|
||||
InstructionSet =
|
||||
p.InstructionSet.Name,
|
||||
InstructionSet = p.InstructionSet.Name,
|
||||
InstructionSetId = p.InstructionSetId
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
@@ -173,6 +166,7 @@ public class ProcessorsController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(ProcessorDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Processor model = await context.Processors.FindAsync(dto.Id);
|
||||
|
||||
@@ -214,7 +208,9 @@ public class ProcessorsController(MarechaiContext context) : ControllerBase
|
||||
public async Task<int> CreateAsync(ProcessorDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new Processor
|
||||
{
|
||||
AddrBus = dto.AddrBus,
|
||||
@@ -257,6 +253,7 @@ public class ProcessorsController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Processor item = await context.Processors.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,8 +44,7 @@ public class ResolutionsController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<ResolutionDto>> GetAsync() => await context.Resolutions
|
||||
.Select(r => new ResolutionDto
|
||||
public Task<List<ResolutionDto>> GetAsync() => context.Resolutions.Select(r => new ResolutionDto
|
||||
{
|
||||
Id = r.Id,
|
||||
Width = r.Width,
|
||||
@@ -69,7 +66,7 @@ public class ResolutionsController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<ResolutionDto> GetAsync(int id) => await context.Resolutions.Where(r => r.Id == id)
|
||||
public Task<ResolutionDto> GetAsync(int id) => context.Resolutions.Where(r => r.Id == id)
|
||||
.Select(r => new ResolutionDto
|
||||
{
|
||||
Id = r.Id,
|
||||
@@ -89,6 +86,7 @@ public class ResolutionsController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(ResolutionDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Resolution model = await context.Resolutions.FindAsync(dto.Id);
|
||||
|
||||
@@ -111,7 +109,9 @@ public class ResolutionsController(MarechaiContext context) : ControllerBase
|
||||
public async Task<int> CreateAsync(ResolutionDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new Resolution
|
||||
{
|
||||
Chars = dto.Chars,
|
||||
@@ -135,6 +135,7 @@ public class ResolutionsController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Resolution item = await context.Resolutions.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class ScreensByMachineController(MarechaiContext context) : ControllerBas
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<ScreenByMachineDto>> GetByMachine(int machineId) => await context.ScreensByMachine
|
||||
public Task<List<ScreenByMachineDto>> GetByMachine(int machineId) => context.ScreensByMachine
|
||||
.Where(s => s.MachineId == machineId)
|
||||
.Select(s => new ScreenByMachineDto
|
||||
{
|
||||
@@ -83,6 +81,7 @@ public class ScreensByMachineController(MarechaiContext context) : ControllerBas
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
ScreensByMachine item = await context.ScreensByMachine.FindAsync(id);
|
||||
|
||||
@@ -100,6 +99,7 @@ public class ScreensByMachineController(MarechaiContext context) : ControllerBas
|
||||
public async Task<long> CreateAsync(int machineId, int screenId)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
if(context.ScreensByMachine.Any(s => s.MachineId == machineId && s.ScreenId == screenId)) return 0;
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -54,25 +52,16 @@ public class ScreensController(MarechaiContext context) : ControllerBase
|
||||
Id = s.Id,
|
||||
Type = s.Type,
|
||||
Width = s.Width,
|
||||
NativeResolutionId =
|
||||
s.NativeResolutionId,
|
||||
NativeResolution =
|
||||
new ResolutionDto
|
||||
NativeResolutionId = s.NativeResolutionId,
|
||||
NativeResolution = new ResolutionDto
|
||||
{
|
||||
Chars = s.NativeResolution
|
||||
.Chars,
|
||||
Colors = s.NativeResolution
|
||||
.Colors,
|
||||
Grayscale = s.NativeResolution
|
||||
.Grayscale,
|
||||
Height = s.NativeResolution
|
||||
.Height,
|
||||
Id =
|
||||
s.NativeResolution.Id,
|
||||
Palette = s.NativeResolution
|
||||
.Palette,
|
||||
Width = s.NativeResolution
|
||||
.Width
|
||||
Chars = s.NativeResolution.Chars,
|
||||
Colors = s.NativeResolution.Colors,
|
||||
Grayscale = s.NativeResolution.Grayscale,
|
||||
Height = s.NativeResolution.Height,
|
||||
Id = s.NativeResolution.Id,
|
||||
Palette = s.NativeResolution.Palette,
|
||||
Width = s.NativeResolution.Width
|
||||
}
|
||||
})
|
||||
.ToListAsync()).OrderBy(s => s.Diagonal)
|
||||
@@ -86,7 +75,7 @@ public class ScreensController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<ScreenDto> GetAsync(int id) => await context.Screens.Where(s => s.Id == id)
|
||||
public Task<ScreenDto> GetAsync(int id) => context.Screens.Where(s => s.Id == id)
|
||||
.Select(s => new ScreenDto
|
||||
{
|
||||
Diagonal = s.Diagonal,
|
||||
@@ -97,12 +86,10 @@ public class ScreensController(MarechaiContext context) : ControllerBase
|
||||
{
|
||||
Chars = s.NativeResolution.Chars,
|
||||
Colors = s.NativeResolution.Colors,
|
||||
Grayscale = s.NativeResolution
|
||||
.Grayscale,
|
||||
Grayscale = s.NativeResolution.Grayscale,
|
||||
Height = s.NativeResolution.Height,
|
||||
Id = s.NativeResolution.Id,
|
||||
Palette =
|
||||
s.NativeResolution.Palette,
|
||||
Palette = s.NativeResolution.Palette,
|
||||
Width = s.NativeResolution.Width
|
||||
},
|
||||
NativeResolutionId = s.NativeResolutionId,
|
||||
@@ -118,6 +105,7 @@ public class ScreensController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(ScreenDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Screen model = await context.Screens.FindAsync(dto.Id);
|
||||
|
||||
@@ -144,7 +132,9 @@ public class ScreensController(MarechaiContext context) : ControllerBase
|
||||
public async Task<int> CreateAsync(ScreenDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new Screen
|
||||
{
|
||||
Diagonal = dto.Diagonal,
|
||||
@@ -168,6 +158,7 @@ public class ScreensController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
Screen item = await context.Screens.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class SoftwareFamiliesController(MarechaiContext context) : ControllerBas
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<SoftwareFamilyDto>> GetAsync() => await context.SoftwareFamilies.OrderBy(b => b.Name)
|
||||
public Task<List<SoftwareFamilyDto>> GetAsync() => context.SoftwareFamilies.OrderBy(b => b.Name)
|
||||
.Select(b => new SoftwareFamilyDto
|
||||
{
|
||||
Id = b.Id,
|
||||
@@ -61,8 +59,7 @@ public class SoftwareFamiliesController(MarechaiContext context) : ControllerBas
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<SoftwareFamilyDto> GetAsync(ulong id) => await context.SoftwareFamilies
|
||||
.Where(b => b.Id == id)
|
||||
public Task<SoftwareFamilyDto> GetAsync(ulong id) => context.SoftwareFamilies.Where(b => b.Id == id)
|
||||
.Select(b => new SoftwareFamilyDto
|
||||
{
|
||||
Id = b.Id,
|
||||
@@ -80,6 +77,7 @@ public class SoftwareFamiliesController(MarechaiContext context) : ControllerBas
|
||||
public async Task UpdateAsync(SoftwareFamilyDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
SoftwareFamily model = await context.SoftwareFamilies.FindAsync(dto.Id);
|
||||
|
||||
@@ -98,7 +96,9 @@ public class SoftwareFamiliesController(MarechaiContext context) : ControllerBas
|
||||
public async Task<ulong> CreateAsync(SoftwareFamilyDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return null;
|
||||
|
||||
var model = new SoftwareFamily
|
||||
{
|
||||
Name = dto.Name,
|
||||
@@ -119,6 +119,7 @@ public class SoftwareFamiliesController(MarechaiContext context) : ControllerBas
|
||||
public async Task DeleteAsync(ulong id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
SoftwareFamily item = await context.SoftwareFamilies.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class SoftwareVariantsController(MarechaiContext context) : ControllerBas
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<SoftwareVariantDto>> GetAsync() => await context.SoftwareVariants
|
||||
public Task<List<SoftwareVariantDto>> GetAsync() => context.SoftwareVariants
|
||||
.OrderBy(b => b.SoftwareVersion.Family.Name)
|
||||
.ThenBy(b => b.SoftwareVersion.Version)
|
||||
.ThenBy(b => b.Name)
|
||||
@@ -79,8 +77,7 @@ public class SoftwareVariantsController(MarechaiContext context) : ControllerBas
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<SoftwareVariantDto> GetAsync(ulong id) => await context.SoftwareVariants
|
||||
.Where(b => b.Id == id)
|
||||
public Task<SoftwareVariantDto> GetAsync(ulong id) => context.SoftwareVariants.Where(b => b.Id == id)
|
||||
.Select(b => new SoftwareVariantDto
|
||||
{
|
||||
Id = b.Id,
|
||||
@@ -91,8 +88,7 @@ public class SoftwareVariantsController(MarechaiContext context) : ControllerBas
|
||||
Parent =
|
||||
b.Parent.Name ?? b.Parent.Version,
|
||||
SoftwareVersionId = b.SoftwareVersionId,
|
||||
SoftwareVersion =
|
||||
b.SoftwareVersion.Name ??
|
||||
SoftwareVersion = b.SoftwareVersion.Name ??
|
||||
b.SoftwareVersion.Version,
|
||||
MinimumMemory = b.MinimumMemory,
|
||||
RecommendedMemory = b.RecommendedMemory,
|
||||
@@ -112,6 +108,7 @@ public class SoftwareVariantsController(MarechaiContext context) : ControllerBas
|
||||
public async Task UpdateAsync(SoftwareVariantDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
SoftwareVariant model = await context.SoftwareVariants.FindAsync(dto.Id);
|
||||
|
||||
@@ -141,7 +138,9 @@ public class SoftwareVariantsController(MarechaiContext context) : ControllerBas
|
||||
public async Task<ulong> CreateAsync(SoftwareVariantDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return null;
|
||||
|
||||
var model = new SoftwareVariant
|
||||
{
|
||||
Name = dto.Name,
|
||||
@@ -172,6 +171,7 @@ public class SoftwareVariantsController(MarechaiContext context) : ControllerBas
|
||||
public async Task DeleteAsync(ulong id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
SoftwareVariant item = await context.SoftwareVariants.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,8 +44,7 @@ public class SoftwareVersionsController(MarechaiContext context) : ControllerBas
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<SoftwareVersionDto>> GetAsync() => await context.SoftwareVersions
|
||||
.OrderBy(b => b.Family.Name)
|
||||
public Task<List<SoftwareVersionDto>> GetAsync() => context.SoftwareVersions.OrderBy(b => b.Family.Name)
|
||||
.ThenBy(b => b.Version)
|
||||
.ThenBy(b => b.Introduced)
|
||||
.Select(b => new SoftwareVersionDto
|
||||
@@ -70,8 +67,7 @@ public class SoftwareVersionsController(MarechaiContext context) : ControllerBas
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<SoftwareVersionDto> GetAsync(ulong id) => await context.SoftwareVersions
|
||||
.Where(b => b.Id == id)
|
||||
public Task<SoftwareVersionDto> GetAsync(ulong id) => context.SoftwareVersions.Where(b => b.Id == id)
|
||||
.Select(b => new SoftwareVersionDto
|
||||
{
|
||||
Id = b.Id,
|
||||
@@ -95,6 +91,7 @@ public class SoftwareVersionsController(MarechaiContext context) : ControllerBas
|
||||
public async Task UpdateAsync(SoftwareVersionDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
SoftwareVersion model = await context.SoftwareVersions.FindAsync(dto.Id);
|
||||
|
||||
@@ -117,7 +114,9 @@ public class SoftwareVersionsController(MarechaiContext context) : ControllerBas
|
||||
public async Task<ulong> CreateAsync(SoftwareVersionDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return null;
|
||||
|
||||
var model = new SoftwareVersion
|
||||
{
|
||||
Name = dto.Name,
|
||||
@@ -142,6 +141,7 @@ public class SoftwareVersionsController(MarechaiContext context) : ControllerBas
|
||||
public async Task DeleteAsync(ulong id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
SoftwareVersion item = await context.SoftwareVersions.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class SoundSynthsByMachineController(MarechaiContext context) : Controlle
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<SoundSynthByMachineDto>> GetByMachine(int machineId) => await context.SoundByMachine
|
||||
public Task<List<SoundSynthByMachineDto>> GetByMachine(int machineId) => context.SoundByMachine
|
||||
.Where(g => g.MachineId == machineId)
|
||||
.Select(g => new SoundSynthByMachineDto
|
||||
{
|
||||
@@ -67,6 +65,7 @@ public class SoundSynthsByMachineController(MarechaiContext context) : Controlle
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
SoundByMachine item = await context.SoundByMachine.FindAsync(id);
|
||||
|
||||
@@ -84,7 +83,9 @@ public class SoundSynthsByMachineController(MarechaiContext context) : Controlle
|
||||
public async Task<long> CreateAsync(int soundSynthId, int machineId)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var item = new SoundByMachine
|
||||
{
|
||||
SoundSynthId = soundSynthId,
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class SoundSynthsController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<SoundSynthDto>> GetAsync() => await context.SoundSynths.OrderBy(s => s.Company.Name)
|
||||
public Task<List<SoundSynthDto>> GetAsync() => context.SoundSynths.OrderBy(s => s.Company.Name)
|
||||
.ThenBy(s => s.Name)
|
||||
.ThenBy(s => s.ModelCode)
|
||||
.Select(s => new SoundSynthDto
|
||||
@@ -70,7 +68,7 @@ public class SoundSynthsController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<SoundSynthDto>> GetByMachineAsync(int machineId) => await context.SoundByMachine
|
||||
public Task<List<SoundSynthDto>> GetByMachineAsync(int machineId) => context.SoundByMachine
|
||||
.Where(s => s.MachineId == machineId)
|
||||
.Select(s => s.SoundSynth)
|
||||
.OrderBy(s => s.Company.Name)
|
||||
@@ -97,7 +95,7 @@ public class SoundSynthsController(MarechaiContext context) : ControllerBase
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<SoundSynthDto> GetAsync(int id) => await context.SoundSynths.Where(s => s.Id == id)
|
||||
public Task<SoundSynthDto> GetAsync(int id) => context.SoundSynths.Where(s => s.Id == id)
|
||||
.Select(s => new SoundSynthDto
|
||||
{
|
||||
Id = s.Id,
|
||||
@@ -122,6 +120,7 @@ public class SoundSynthsController(MarechaiContext context) : ControllerBase
|
||||
public async Task UpdateAsync(SoundSynthDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
SoundSynth model = await context.SoundSynths.FindAsync(dto.Id);
|
||||
|
||||
@@ -148,7 +147,9 @@ public class SoundSynthsController(MarechaiContext context) : ControllerBase
|
||||
public async Task<int> CreateAsync(SoundSynthDto dto)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var model = new SoundSynth
|
||||
{
|
||||
Depth = dto.Depth,
|
||||
@@ -176,6 +177,7 @@ public class SoundSynthsController(MarechaiContext context) : ControllerBase
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
SoundSynth item = await context.SoundSynths.FindAsync(id);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// Copyright © 2003-2025 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Server.Controllers;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class StorageByMachineController(MarechaiContext context) : ControllerBas
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<List<StorageByMachineDto>> GetByMachine(int machineId) => await context.StorageByMachine
|
||||
public Task<List<StorageByMachineDto>> GetByMachine(int machineId) => context.StorageByMachine
|
||||
.Where(s => s.MachineId == machineId)
|
||||
.Select(s => new StorageByMachineDto
|
||||
{
|
||||
@@ -68,6 +66,7 @@ public class StorageByMachineController(MarechaiContext context) : ControllerBas
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return;
|
||||
StorageByMachine item = await context.StorageByMachine.FindAsync(id);
|
||||
|
||||
@@ -85,7 +84,9 @@ public class StorageByMachineController(MarechaiContext context) : ControllerBas
|
||||
public async Task<long> CreateAsync(int machineId, StorageType type, StorageInterface @interface, long? capacity)
|
||||
{
|
||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||
|
||||
if(userId is null) return 0;
|
||||
|
||||
var item = new StorageByMachine
|
||||
{
|
||||
MachineId = machineId,
|
||||
|
||||
Reference in New Issue
Block a user