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.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -53,34 +52,29 @@ public class BookScansController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(p => new BookScanDto
|
||||||
{
|
{
|
||||||
Author = p.Author,
|
Author = p.Author,
|
||||||
BookId = p.Book.Id,
|
BookId = p.Book.Id,
|
||||||
ColorSpace = p.ColorSpace,
|
ColorSpace = p.ColorSpace,
|
||||||
Comments = p.Comments,
|
Comments = p.Comments,
|
||||||
CreationDate = p.CreationDate,
|
CreationDate = p.CreationDate,
|
||||||
ExifVersion = p.ExifVersion,
|
ExifVersion = p.ExifVersion,
|
||||||
HorizontalResolution =
|
HorizontalResolution = p.HorizontalResolution,
|
||||||
p.HorizontalResolution,
|
Id = p.Id,
|
||||||
Id = p.Id,
|
ResolutionUnit = p.ResolutionUnit,
|
||||||
ResolutionUnit =
|
Page = p.Page,
|
||||||
p.ResolutionUnit,
|
ScannerManufacturer = p.ScannerManufacturer,
|
||||||
Page = p.Page,
|
ScannerModel = p.ScannerModel,
|
||||||
ScannerManufacturer =
|
SoftwareUsed = p.SoftwareUsed,
|
||||||
p.ScannerManufacturer,
|
Type = p.Type,
|
||||||
ScannerModel = p.ScannerModel,
|
UploadDate = p.UploadDate,
|
||||||
SoftwareUsed = p.SoftwareUsed,
|
UserId = p.UserId,
|
||||||
Type = p.Type,
|
VerticalResolution = p.VerticalResolution,
|
||||||
UploadDate = p.UploadDate,
|
OriginalExtension = p.OriginalExtension
|
||||||
UserId = p.UserId,
|
})
|
||||||
VerticalResolution =
|
.FirstOrDefaultAsync();
|
||||||
p.VerticalResolution,
|
|
||||||
OriginalExtension =
|
|
||||||
p.OriginalExtension
|
|
||||||
})
|
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -89,6 +83,7 @@ public class BookScansController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(BookScanDto dto)
|
public async Task UpdateAsync(BookScanDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
BookScan model = await context.BookScans.FindAsync(dto.Id);
|
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)
|
public async Task<Guid> CreateAsync(BookScanDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return null;
|
if(userId is null) return null;
|
||||||
|
|
||||||
var model = new BookScan
|
var model = new BookScan
|
||||||
{
|
{
|
||||||
Author = dto.Author,
|
Author = dto.Author,
|
||||||
@@ -154,6 +151,7 @@ public class BookScansController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(Guid id)
|
public async Task DeleteAsync(Guid id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
BookScan item = await context.BookScans.FindAsync(id);
|
BookScan item = await context.BookScans.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,47 +44,47 @@ public class BooksController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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.Published)
|
||||||
.ThenBy(b => b.Title)
|
.ThenBy(b => b.Title)
|
||||||
.Select(b => new BookDto
|
.Select(b => new BookDto
|
||||||
{
|
{
|
||||||
Id = b.Id,
|
Id = b.Id,
|
||||||
Title = b.Title,
|
Title = b.Title,
|
||||||
NativeTitle = b.NativeTitle,
|
NativeTitle = b.NativeTitle,
|
||||||
Published = b.Published,
|
Published = b.Published,
|
||||||
Synopsis = b.Synopsis,
|
Synopsis = b.Synopsis,
|
||||||
Isbn = b.Isbn,
|
Isbn = b.Isbn,
|
||||||
CountryId = b.CountryId,
|
CountryId = b.CountryId,
|
||||||
Pages = b.Pages,
|
Pages = b.Pages,
|
||||||
Edition = b.Edition,
|
Edition = b.Edition,
|
||||||
PreviousId = b.PreviousId,
|
PreviousId = b.PreviousId,
|
||||||
SourceId = b.SourceId,
|
SourceId = b.SourceId,
|
||||||
Country = b.Country.Name
|
Country = b.Country.Name
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(b => new BookDto
|
||||||
{
|
{
|
||||||
Id = b.Id,
|
Id = b.Id,
|
||||||
Title = b.Title,
|
Title = b.Title,
|
||||||
NativeTitle = b.NativeTitle,
|
NativeTitle = b.NativeTitle,
|
||||||
Published = b.Published,
|
Published = b.Published,
|
||||||
Synopsis = b.Synopsis,
|
Synopsis = b.Synopsis,
|
||||||
Isbn = b.Isbn,
|
Isbn = b.Isbn,
|
||||||
CountryId = b.CountryId,
|
CountryId = b.CountryId,
|
||||||
Pages = b.Pages,
|
Pages = b.Pages,
|
||||||
Edition = b.Edition,
|
Edition = b.Edition,
|
||||||
PreviousId = b.PreviousId,
|
PreviousId = b.PreviousId,
|
||||||
SourceId = b.SourceId,
|
SourceId = b.SourceId,
|
||||||
Country = b.Country.Name
|
Country = b.Country.Name
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -95,6 +93,7 @@ public class BooksController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(BookDto dto)
|
public async Task UpdateAsync(BookDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Book model = await context.Books.FindAsync(dto.Id);
|
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)
|
public async Task<long> CreateAsync(BookDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new Book
|
var model = new Book
|
||||||
{
|
{
|
||||||
Title = dto.Title,
|
Title = dto.Title,
|
||||||
@@ -155,6 +156,7 @@ public class BooksController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(long id)
|
public async Task DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Book item = await context.Books.FindAsync(id);
|
Book item = await context.Books.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,20 +44,20 @@ public class CompaniesByBookController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.Where(p => p.BookId == bookId)
|
||||||
.Select(p => new CompanyByBookDto
|
.Select(p => new CompanyByBookDto
|
||||||
{
|
{
|
||||||
Id = p.Id,
|
Id = p.Id,
|
||||||
Company = p.Company.Name,
|
Company = p.Company.Name,
|
||||||
CompanyId = p.CompanyId,
|
CompanyId = p.CompanyId,
|
||||||
RoleId = p.RoleId,
|
RoleId = p.RoleId,
|
||||||
Role = p.Role.Name,
|
Role = p.Role.Name,
|
||||||
BookId = p.BookId
|
BookId = p.BookId
|
||||||
})
|
})
|
||||||
.OrderBy(p => p.Company)
|
.OrderBy(p => p.Company)
|
||||||
.ThenBy(p => p.Role)
|
.ThenBy(p => p.Role)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -68,6 +66,7 @@ public class CompaniesByBookController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(long id)
|
public async Task DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
CompaniesByBook item = await context.CompaniesByBooks.FindAsync(id);
|
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)
|
public async Task<long> CreateAsync(int companyId, long bookId, string roleId)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var item = new CompaniesByBook
|
var item = new CompaniesByBook
|
||||||
{
|
{
|
||||||
CompanyId = companyId,
|
CompanyId = companyId,
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,20 +44,20 @@ public class CompaniesByDocumentController(MarechaiContext context) : Controller
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<CompanyByDocumentDto>> GetByDocument(long documentId) => await context
|
public Task<List<CompanyByDocumentDto>> GetByDocument(long documentId) => context.CompaniesByDocuments
|
||||||
.CompaniesByDocuments.Where(p => p.DocumentId == documentId)
|
.Where(p => p.DocumentId == documentId)
|
||||||
.Select(p => new CompanyByDocumentDto
|
.Select(p => new CompanyByDocumentDto
|
||||||
{
|
{
|
||||||
Id = p.Id,
|
Id = p.Id,
|
||||||
Company = p.Company.Name,
|
Company = p.Company.Name,
|
||||||
CompanyId = p.CompanyId,
|
CompanyId = p.CompanyId,
|
||||||
RoleId = p.RoleId,
|
RoleId = p.RoleId,
|
||||||
Role = p.Role.Name,
|
Role = p.Role.Name,
|
||||||
DocumentId = p.DocumentId
|
DocumentId = p.DocumentId
|
||||||
})
|
})
|
||||||
.OrderBy(p => p.Company)
|
.OrderBy(p => p.Company)
|
||||||
.ThenBy(p => p.Role)
|
.ThenBy(p => p.Role)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -68,6 +66,7 @@ public class CompaniesByDocumentController(MarechaiContext context) : Controller
|
|||||||
public async Task DeleteAsync(long id)
|
public async Task DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
CompaniesByDocument item = await context.CompaniesByDocuments.FindAsync(id);
|
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)
|
public async Task<long> CreateAsync(int companyId, long documentId, string roleId)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var item = new CompaniesByDocument
|
var item = new CompaniesByDocument
|
||||||
{
|
{
|
||||||
CompanyId = companyId,
|
CompanyId = companyId,
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,20 +44,20 @@ public class CompaniesByMagazineController(MarechaiContext context) : Controller
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<CompanyByMagazineDto>> GetByMagazine(long magazineId) => await context
|
public Task<List<CompanyByMagazineDto>> GetByMagazine(long magazineId) => context.CompaniesByMagazines
|
||||||
.CompaniesByMagazines.Where(p => p.MagazineId == magazineId)
|
.Where(p => p.MagazineId == magazineId)
|
||||||
.Select(p => new CompanyByMagazineDto
|
.Select(p => new CompanyByMagazineDto
|
||||||
{
|
{
|
||||||
Id = p.Id,
|
Id = p.Id,
|
||||||
Company = p.Company.Name,
|
Company = p.Company.Name,
|
||||||
CompanyId = p.CompanyId,
|
CompanyId = p.CompanyId,
|
||||||
RoleId = p.RoleId,
|
RoleId = p.RoleId,
|
||||||
Role = p.Role.Name,
|
Role = p.Role.Name,
|
||||||
MagazineId = p.MagazineId
|
MagazineId = p.MagazineId
|
||||||
})
|
})
|
||||||
.OrderBy(p => p.Company)
|
.OrderBy(p => p.Company)
|
||||||
.ThenBy(p => p.Role)
|
.ThenBy(p => p.Role)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -68,6 +66,7 @@ public class CompaniesByMagazineController(MarechaiContext context) : Controller
|
|||||||
public async Task DeleteAsync(long id)
|
public async Task DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
CompaniesByMagazine item = await context.CompaniesByMagazines.FindAsync(id);
|
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)
|
public async Task<long> CreateAsync(int companyId, long magazineId, string roleId)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var item = new CompaniesByMagazine
|
var item = new CompaniesByMagazine
|
||||||
{
|
{
|
||||||
CompanyId = companyId,
|
CompanyId = companyId,
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -46,80 +45,70 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.OrderBy(c => c.Name)
|
||||||
.Select(c => new CompanyDto
|
.Select(c => new CompanyDto
|
||||||
{
|
{
|
||||||
Id = c.Id,
|
Id = c.Id,
|
||||||
LastLogo =
|
LastLogo =
|
||||||
c.Logos
|
c.Logos.OrderByDescending(l => l.Year)
|
||||||
.OrderByDescending(l => l.Year)
|
.FirstOrDefault()
|
||||||
.FirstOrDefault()
|
.Guid,
|
||||||
.Guid,
|
Name = c.Name,
|
||||||
Name = c.Name,
|
Founded = c.Founded,
|
||||||
Founded = c.Founded,
|
Sold = c.Sold,
|
||||||
Sold = c.Sold,
|
SoldToId = c.SoldToId,
|
||||||
SoldToId = c.SoldToId,
|
CountryId = c.CountryId,
|
||||||
CountryId = c.CountryId,
|
Status = c.Status,
|
||||||
Status = c.Status,
|
Website = c.Website,
|
||||||
Website = c.Website,
|
Twitter = c.Twitter,
|
||||||
Twitter = c.Twitter,
|
Facebook = c.Facebook,
|
||||||
Facebook = c.Facebook,
|
Address = c.Address,
|
||||||
Address = c.Address,
|
City = c.City,
|
||||||
City = c.City,
|
Province = c.Province,
|
||||||
Province = c.Province,
|
PostalCode = c.PostalCode,
|
||||||
PostalCode = c.PostalCode,
|
Country = c.Country.Name,
|
||||||
Country = c.Country.Name,
|
FoundedDayIsUnknown = c.FoundedDayIsUnknown,
|
||||||
FoundedDayIsUnknown =
|
FoundedMonthIsUnknown = c.FoundedMonthIsUnknown,
|
||||||
c.FoundedDayIsUnknown,
|
SoldDayIsUnknown = c.SoldDayIsUnknown,
|
||||||
FoundedMonthIsUnknown =
|
SoldMonthIsUnknown = c.SoldMonthIsUnknown,
|
||||||
c.FoundedMonthIsUnknown,
|
LegalName = c.LegalName
|
||||||
SoldDayIsUnknown =
|
})
|
||||||
c.SoldDayIsUnknown,
|
.ToListAsync();
|
||||||
SoldMonthIsUnknown =
|
|
||||||
c.SoldMonthIsUnknown,
|
|
||||||
LegalName = c.LegalName
|
|
||||||
})
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(c => new CompanyDto
|
||||||
{
|
{
|
||||||
Id = c.Id,
|
Id = c.Id,
|
||||||
LastLogo =
|
LastLogo =
|
||||||
c.Logos
|
c.Logos.OrderByDescending(l => l.Year)
|
||||||
.OrderByDescending(l => l.Year)
|
.FirstOrDefault()
|
||||||
.FirstOrDefault()
|
.Guid,
|
||||||
.Guid,
|
Name = c.Name,
|
||||||
Name = c.Name,
|
Founded = c.Founded,
|
||||||
Founded = c.Founded,
|
Sold = c.Sold,
|
||||||
Sold = c.Sold,
|
SoldToId = c.SoldToId,
|
||||||
SoldToId = c.SoldToId,
|
CountryId = c.CountryId,
|
||||||
CountryId = c.CountryId,
|
Status = c.Status,
|
||||||
Status = c.Status,
|
Website = c.Website,
|
||||||
Website = c.Website,
|
Twitter = c.Twitter,
|
||||||
Twitter = c.Twitter,
|
Facebook = c.Facebook,
|
||||||
Facebook = c.Facebook,
|
Address = c.Address,
|
||||||
Address = c.Address,
|
City = c.City,
|
||||||
City = c.City,
|
Province = c.Province,
|
||||||
Province = c.Province,
|
PostalCode = c.PostalCode,
|
||||||
PostalCode = c.PostalCode,
|
Country = c.Country.Name,
|
||||||
Country = c.Country.Name,
|
FoundedDayIsUnknown = c.FoundedDayIsUnknown,
|
||||||
FoundedDayIsUnknown =
|
FoundedMonthIsUnknown = c.FoundedMonthIsUnknown,
|
||||||
c.FoundedDayIsUnknown,
|
SoldDayIsUnknown = c.SoldDayIsUnknown,
|
||||||
FoundedMonthIsUnknown =
|
SoldMonthIsUnknown = c.SoldMonthIsUnknown,
|
||||||
c.FoundedMonthIsUnknown,
|
LegalName = c.LegalName
|
||||||
SoldDayIsUnknown =
|
})
|
||||||
c.SoldDayIsUnknown,
|
.FirstOrDefaultAsync();
|
||||||
SoldMonthIsUnknown =
|
|
||||||
c.SoldMonthIsUnknown,
|
|
||||||
LegalName = c.LegalName
|
|
||||||
})
|
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -128,6 +117,7 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
|||||||
public async Task UpdateAsync(CompanyDto dto)
|
public async Task UpdateAsync(CompanyDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Company model = await context.Companies.FindAsync(dto.Id);
|
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)
|
public async Task<int> CreateAsync(CompanyDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new Company
|
var model = new Company
|
||||||
{
|
{
|
||||||
Name = dto.Name,
|
Name = dto.Name,
|
||||||
@@ -194,15 +186,15 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.OrderBy(m => m.Name)
|
||||||
.Select(m => new Machine
|
.Select(m => new Machine
|
||||||
{
|
{
|
||||||
Id = m.Id,
|
Id = m.Id,
|
||||||
Name = m.Name,
|
Name = m.Name,
|
||||||
Type = m.Type
|
Type = m.Type
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
@@ -219,12 +211,12 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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,
|
Id = c.Id,
|
||||||
Name = c.Name
|
Name = c.Name
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync(c => c.Id == id);
|
.FirstOrDefaultAsync(c => c.Id == id);
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
@@ -237,8 +229,7 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public Task<List<CompanyDto>> GetCompaniesByCountryAsync(int countryId) => context.Companies
|
public Task<List<CompanyDto>> GetCompaniesByCountryAsync(int countryId) => context.Companies.Include(c => c.Logos)
|
||||||
.Include(c => c.Logos)
|
|
||||||
.Where(c => c.CountryId == countryId)
|
.Where(c => c.CountryId == countryId)
|
||||||
.OrderBy(c => c.Name)
|
.OrderBy(c => c.Name)
|
||||||
.Select(c => new CompanyDto
|
.Select(c => new CompanyDto
|
||||||
@@ -271,6 +262,7 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
|||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Company item = await context.Companies.FindAsync(id);
|
Company item = await context.Companies.FindAsync(id);
|
||||||
|
|
||||||
@@ -285,24 +277,25 @@ public class CompaniesController(MarechaiContext context, IStringLocalizer<Compa
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.Where(d => d.CompanyId == id)
|
||||||
.Select(d => new CompanyDescriptionDto
|
.Select(d => new CompanyDescriptionDto
|
||||||
{
|
{
|
||||||
Id = d.Id,
|
Id = d.Id,
|
||||||
CompanyId = d.CompanyId,
|
CompanyId = d.CompanyId,
|
||||||
Html = d.Html,
|
Html = d.Html,
|
||||||
Markdown = d.Text
|
Markdown = d.Text
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<int> CreateOrUpdateDescriptionAsync(int id, CompanyDescriptionDto description)
|
public async Task<int> CreateOrUpdateDescriptionAsync(int id, CompanyDescriptionDto description)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
CompanyDescription current = await context.CompanyDescriptions.FirstOrDefaultAsync(d => d.CompanyId == id);
|
CompanyDescription current = await context.CompanyDescriptions.FirstOrDefaultAsync(d => d.CompanyId == id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,10 +23,7 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Claims;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Marechai.Data.Dtos;
|
using Marechai.Data.Dtos;
|
||||||
using Marechai.Database.Models;
|
using Marechai.Database.Models;
|
||||||
@@ -34,7 +31,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -54,68 +50,71 @@ public class ComputersController(MarechaiContext context) : ControllerBase
|
|||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public Task<int> GetMinimumYearAsync() => context.Machines
|
public Task<int> GetMinimumYearAsync() => context.Machines
|
||||||
.Where(t => t.Type == MachineType.Computer &&
|
.Where(t => t.Type == MachineType.Computer &&
|
||||||
t.Introduced.HasValue &&
|
t.Introduced.HasValue &&
|
||||||
t.Introduced.Value.Year > 1000)
|
t.Introduced.Value.Year > 1000)
|
||||||
.MinAsync(t => t.Introduced.Value.Year);
|
.MinAsync(t => t.Introduced.Value.Year);
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public Task<int> GetMaximumYearAsync() => context.Machines
|
public Task<int> GetMaximumYearAsync() => context.Machines
|
||||||
.Where(t => t.Type == MachineType.Computer &&
|
.Where(t => t.Type == MachineType.Computer &&
|
||||||
t.Introduced.HasValue &&
|
t.Introduced.HasValue &&
|
||||||
t.Introduced.Value.Year > 1000)
|
t.Introduced.Value.Year > 1000)
|
||||||
.MaxAsync(t => t.Introduced.Value.Year);
|
.MaxAsync(t => t.Introduced.Value.Year);
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<MachineDto>> GetComputersByLetterAsync(char c) => await context.Machines
|
public Task<List<MachineDto>> GetComputersByLetterAsync(char c) => context.Machines.Include(m => m.Company)
|
||||||
.Include(m => m.Company)
|
.Where(m =>
|
||||||
.Where(m => m.Type == MachineType.Computer && EF.Functions.Like(m.Name, $"{c}%"))
|
m.Type == MachineType.Computer &&
|
||||||
.OrderBy(m => m.Company.Name)
|
EF.Functions.Like(m.Name, $"{c}%"))
|
||||||
.ThenBy(m => m.Name)
|
.OrderBy(m => m.Company.Name)
|
||||||
.Select(m => new MachineDto
|
.ThenBy(m => m.Name)
|
||||||
{
|
.Select(m => new MachineDto
|
||||||
Id = m.Id,
|
{
|
||||||
Name = m.Name,
|
Id = m.Id,
|
||||||
Company = m.Company.Name
|
Name = m.Name,
|
||||||
})
|
Company = m.Company.Name
|
||||||
.ToListAsync();
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<MachineDto>> GetComputersByYearAsync(int year) => await context.Machines
|
public Task<List<MachineDto>> GetComputersByYearAsync(int year) => context.Machines.Include(m => m.Company)
|
||||||
.Include(m => m.Company)
|
.Where(m =>
|
||||||
.Where(m => m.Type == MachineType.Computer && m.Introduced != null && m.Introduced.Value.Year == year)
|
m.Type == MachineType.Computer &&
|
||||||
.OrderBy(m => m.Company.Name)
|
m.Introduced != null &&
|
||||||
.ThenBy(m => m.Name)
|
m.Introduced.Value.Year == year)
|
||||||
.Select(m => new MachineDto
|
.OrderBy(m => m.Company.Name)
|
||||||
{
|
.ThenBy(m => m.Name)
|
||||||
Id = m.Id,
|
.Select(m => new MachineDto
|
||||||
Name = m.Name,
|
{
|
||||||
Company = m.Company.Name
|
Id = m.Id,
|
||||||
})
|
Name = m.Name,
|
||||||
.ToListAsync();
|
Company = m.Company.Name
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.Where(m => m.Type == MachineType.Computer)
|
||||||
.OrderBy(m => m.Company.Name)
|
.OrderBy(m => m.Company.Name)
|
||||||
.ThenBy(m => m.Name)
|
.ThenBy(m => m.Name)
|
||||||
.Select(m => new MachineDto
|
.Select(m => new MachineDto
|
||||||
{
|
{
|
||||||
Id = m.Id,
|
Id = m.Id,
|
||||||
Name = m.Name,
|
Name = m.Name,
|
||||||
Company = m.Company.Name
|
Company = m.Company.Name
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
@@ -23,10 +23,7 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Claims;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Marechai.Data.Dtos;
|
using Marechai.Data.Dtos;
|
||||||
using Marechai.Database.Models;
|
using Marechai.Database.Models;
|
||||||
@@ -34,7 +31,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -54,68 +50,71 @@ public class ConsolesController(MarechaiContext context) : ControllerBase
|
|||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public Task<int> GetMinimumYearAsync() => context.Machines
|
public Task<int> GetMinimumYearAsync() => context.Machines
|
||||||
.Where(t => t.Type == MachineType.Console &&
|
.Where(t => t.Type == MachineType.Console &&
|
||||||
t.Introduced.HasValue &&
|
t.Introduced.HasValue &&
|
||||||
t.Introduced.Value.Year > 1000)
|
t.Introduced.Value.Year > 1000)
|
||||||
.MinAsync(t => t.Introduced.Value.Year);
|
.MinAsync(t => t.Introduced.Value.Year);
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public Task<int> GetMaximumYearAsync() => context.Machines
|
public Task<int> GetMaximumYearAsync() => context.Machines
|
||||||
.Where(t => t.Type == MachineType.Console &&
|
.Where(t => t.Type == MachineType.Console &&
|
||||||
t.Introduced.HasValue &&
|
t.Introduced.HasValue &&
|
||||||
t.Introduced.Value.Year > 1000)
|
t.Introduced.Value.Year > 1000)
|
||||||
.MaxAsync(t => t.Introduced.Value.Year);
|
.MaxAsync(t => t.Introduced.Value.Year);
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<MachineDto>> GetConsolesByLetterAsync(char c) => await context.Machines
|
public Task<List<MachineDto>> GetConsolesByLetterAsync(char c) => context.Machines.Include(m => m.Company)
|
||||||
.Include(m => m.Company)
|
.Where(m =>
|
||||||
.Where(m => m.Type == MachineType.Console && EF.Functions.Like(m.Name, $"{c}%"))
|
m.Type == MachineType.Console &&
|
||||||
.OrderBy(m => m.Company.Name)
|
EF.Functions.Like(m.Name, $"{c}%"))
|
||||||
.ThenBy(m => m.Name)
|
.OrderBy(m => m.Company.Name)
|
||||||
.Select(m => new MachineDto
|
.ThenBy(m => m.Name)
|
||||||
{
|
.Select(m => new MachineDto
|
||||||
Id = m.Id,
|
{
|
||||||
Name = m.Name,
|
Id = m.Id,
|
||||||
Company = m.Company.Name
|
Name = m.Name,
|
||||||
})
|
Company = m.Company.Name
|
||||||
.ToListAsync();
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<MachineDto>> GetConsolesByYearAsync(int year) => await context.Machines
|
public Task<List<MachineDto>> GetConsolesByYearAsync(int year) => context.Machines.Include(m => m.Company)
|
||||||
.Include(m => m.Company)
|
.Where(m =>
|
||||||
.Where(m => m.Type == MachineType.Console && m.Introduced != null && m.Introduced.Value.Year == year)
|
m.Type == MachineType.Console &&
|
||||||
.OrderBy(m => m.Company.Name)
|
m.Introduced != null &&
|
||||||
.ThenBy(m => m.Name)
|
m.Introduced.Value.Year == year)
|
||||||
.Select(m => new MachineDto
|
.OrderBy(m => m.Company.Name)
|
||||||
{
|
.ThenBy(m => m.Name)
|
||||||
Id = m.Id,
|
.Select(m => new MachineDto
|
||||||
Name = m.Name,
|
{
|
||||||
Company = m.Company.Name
|
Id = m.Id,
|
||||||
})
|
Name = m.Name,
|
||||||
.ToListAsync();
|
Company = m.Company.Name
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.Where(m => m.Type == MachineType.Console)
|
||||||
.OrderBy(m => m.Company.Name)
|
.OrderBy(m => m.Company.Name)
|
||||||
.ThenBy(m => m.Name)
|
.ThenBy(m => m.Name)
|
||||||
.Select(m => new MachineDto
|
.Select(m => new MachineDto
|
||||||
{
|
{
|
||||||
Id = m.Id,
|
Id = m.Id,
|
||||||
Name = m.Name,
|
Name = m.Name,
|
||||||
Company = m.Company.Name
|
Company = m.Company.Name
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,34 +44,32 @@ public class CurrencyInflationController(MarechaiContext context) : ControllerBa
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<CurrencyInflationDto>> GetAsync() => await context.CurrenciesInflation
|
public Task<List<CurrencyInflationDto>> GetAsync() => context.CurrenciesInflation.OrderBy(i => i.Currency.Name)
|
||||||
.OrderBy(i => i.Currency.Name)
|
.ThenBy(i => i.Year)
|
||||||
.ThenBy(i => i.Year)
|
.Select(i => new CurrencyInflationDto
|
||||||
.Select(i => new CurrencyInflationDto
|
{
|
||||||
{
|
Id = i.Id,
|
||||||
Id = i.Id,
|
CurrencyCode = i.Currency.Code,
|
||||||
CurrencyCode = i.Currency.Code,
|
CurrencyName = i.Currency.Name,
|
||||||
CurrencyName = i.Currency.Name,
|
Year = i.Year,
|
||||||
Year = i.Year,
|
Inflation = i.Inflation
|
||||||
Inflation = i.Inflation
|
})
|
||||||
})
|
.ToListAsync();
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<CurrencyInflationDto> GetAsync(int id) => await context.CurrenciesInflation
|
public Task<CurrencyInflationDto> GetAsync(int id) => context.CurrenciesInflation.Where(b => b.Id == id)
|
||||||
.Where(b => b.Id == id)
|
.Select(i => new CurrencyInflationDto
|
||||||
.Select(i => new CurrencyInflationDto
|
{
|
||||||
{
|
Id = i.Id,
|
||||||
Id = i.Id,
|
CurrencyCode = i.Currency.Code,
|
||||||
CurrencyCode = i.Currency.Code,
|
CurrencyName = i.Currency.Name,
|
||||||
CurrencyName = i.Currency.Name,
|
Year = i.Year,
|
||||||
Year = i.Year,
|
Inflation = i.Inflation
|
||||||
Inflation = i.Inflation
|
})
|
||||||
})
|
.FirstOrDefaultAsync();
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -82,6 +78,7 @@ public class CurrencyInflationController(MarechaiContext context) : ControllerBa
|
|||||||
public async Task UpdateAsync(CurrencyInflationDto dto)
|
public async Task UpdateAsync(CurrencyInflationDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
CurrencyInflation model = await context.CurrenciesInflation.FindAsync(dto.Id);
|
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)
|
public async Task<int> CreateAsync(CurrencyInflationDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new CurrencyInflation
|
var model = new CurrencyInflation
|
||||||
{
|
{
|
||||||
CurrencyCode = dto.CurrencyCode,
|
CurrencyCode = dto.CurrencyCode,
|
||||||
@@ -121,6 +120,7 @@ public class CurrencyInflationController(MarechaiContext context) : ControllerBa
|
|||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
CurrencyInflation item = await context.CurrenciesInflation.FindAsync(id);
|
CurrencyInflation item = await context.CurrenciesInflation.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,42 +44,40 @@ public class CurrencyPeggingController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<CurrencyPeggingDto>> GetAsync() => await context.CurrenciesPegging
|
public Task<List<CurrencyPeggingDto>> GetAsync() => context.CurrenciesPegging.OrderBy(i => i.Source.Name)
|
||||||
.OrderBy(i => i.Source.Name)
|
.ThenBy(i => i.Destination.Name)
|
||||||
.ThenBy(i => i.Destination.Name)
|
.ThenBy(i => i.Start)
|
||||||
.ThenBy(i => i.Start)
|
.ThenBy(i => i.End)
|
||||||
.ThenBy(i => i.End)
|
.Select(i => new CurrencyPeggingDto
|
||||||
.Select(i => new CurrencyPeggingDto
|
{
|
||||||
{
|
Id = i.Id,
|
||||||
Id = i.Id,
|
SourceCode = i.Source.Code,
|
||||||
SourceCode = i.Source.Code,
|
SourceName = i.Source.Name,
|
||||||
SourceName = i.Source.Name,
|
DestinationCode = i.Source.Code,
|
||||||
DestinationCode = i.Source.Code,
|
DestinationName = i.Source.Name,
|
||||||
DestinationName = i.Source.Name,
|
Ratio = i.Ratio,
|
||||||
Ratio = i.Ratio,
|
Start = i.Start,
|
||||||
Start = i.Start,
|
End = i.End
|
||||||
End = i.End
|
})
|
||||||
})
|
.ToListAsync();
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<CurrencyPeggingDto> GetAsync(int id) => await context.CurrenciesPegging
|
public Task<CurrencyPeggingDto> GetAsync(int id) => context.CurrenciesPegging.Where(b => b.Id == id)
|
||||||
.Where(b => b.Id == id)
|
.Select(i => new CurrencyPeggingDto
|
||||||
.Select(i => new CurrencyPeggingDto
|
{
|
||||||
{
|
Id = i.Id,
|
||||||
Id = i.Id,
|
SourceCode = i.Source.Code,
|
||||||
SourceCode = i.Source.Code,
|
SourceName = i.Source.Name,
|
||||||
SourceName = i.Source.Name,
|
DestinationCode = i.Destination.Code,
|
||||||
DestinationCode = i.Destination.Code,
|
DestinationName = i.Destination.Name,
|
||||||
DestinationName = i.Destination.Name,
|
Ratio = i.Ratio,
|
||||||
Ratio = i.Ratio,
|
Start = i.Start,
|
||||||
Start = i.Start,
|
End = i.End
|
||||||
End = i.End
|
})
|
||||||
})
|
.FirstOrDefaultAsync();
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -90,6 +86,7 @@ public class CurrencyPeggingController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(CurrencyPeggingDto dto)
|
public async Task UpdateAsync(CurrencyPeggingDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
CurrencyPegging model = await context.CurrenciesPegging.FindAsync(dto.Id);
|
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)
|
public async Task<int> CreateAsync(CurrencyPeggingDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new CurrencyPegging
|
var model = new CurrencyPegging
|
||||||
{
|
{
|
||||||
SourceCode = dto.SourceCode,
|
SourceCode = dto.SourceCode,
|
||||||
@@ -133,6 +132,7 @@ public class CurrencyPeggingController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
CurrencyPegging item = await context.CurrenciesPegging.FindAsync(id);
|
CurrencyPegging item = await context.CurrenciesPegging.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,30 +44,28 @@ public class DocumentCompaniesController(MarechaiContext context) : ControllerBa
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<DocumentCompanyDto>> GetAsync() => await context.DocumentCompanies
|
public Task<List<DocumentCompanyDto>> GetAsync() => context.DocumentCompanies.OrderBy(c => c.Name)
|
||||||
.OrderBy(c => c.Name)
|
.Select(d => new DocumentCompanyDto
|
||||||
.Select(d => new DocumentCompanyDto
|
{
|
||||||
{
|
Id = d.Id,
|
||||||
Id = d.Id,
|
Name = d.Name,
|
||||||
Name = d.Name,
|
Company = d.Company.Name,
|
||||||
Company = d.Company.Name,
|
CompanyId = d.CompanyId
|
||||||
CompanyId = d.CompanyId
|
})
|
||||||
})
|
.ToListAsync();
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<DocumentCompanyDto> GetAsync(int id) => await context.DocumentCompanies
|
public Task<DocumentCompanyDto> GetAsync(int id) => context.DocumentCompanies.Where(d => d.Id == id)
|
||||||
.Where(d => d.Id == id)
|
.Select(d => new DocumentCompanyDto
|
||||||
.Select(d => new DocumentCompanyDto
|
{
|
||||||
{
|
Id = d.Id,
|
||||||
Id = d.Id,
|
Name = d.Name,
|
||||||
Name = d.Name,
|
CompanyId = d.CompanyId
|
||||||
CompanyId = d.CompanyId
|
})
|
||||||
})
|
.FirstOrDefaultAsync();
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -78,6 +74,7 @@ public class DocumentCompaniesController(MarechaiContext context) : ControllerBa
|
|||||||
public async Task UpdateAsync(DocumentCompanyDto dto)
|
public async Task UpdateAsync(DocumentCompanyDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
DocumentCompany model = await context.DocumentCompanies.FindAsync(dto.Id);
|
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)
|
public async Task<int> CreateAsync(DocumentCompanyDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new DocumentCompany
|
var model = new DocumentCompany
|
||||||
{
|
{
|
||||||
CompanyId = dto.CompanyId,
|
CompanyId = dto.CompanyId,
|
||||||
@@ -116,6 +115,7 @@ public class DocumentCompaniesController(MarechaiContext context) : ControllerBa
|
|||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
DocumentCompany item = await context.DocumentCompanies.FindAsync(id);
|
DocumentCompany item = await context.DocumentCompanies.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,35 +44,34 @@ public class DocumentPeopleController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<DocumentPersonDto>> GetAsync() => await context.DocumentPeople
|
public Task<List<DocumentPersonDto>> GetAsync() => context.DocumentPeople.OrderBy(d => d.DisplayName)
|
||||||
.OrderBy(d => d.DisplayName)
|
.ThenBy(d => d.Alias)
|
||||||
.ThenBy(d => d.Alias)
|
.ThenBy(d => d.Name)
|
||||||
.ThenBy(d => d.Name)
|
.ThenBy(d => d.Surname)
|
||||||
.ThenBy(d => d.Surname)
|
.Select(d => new DocumentPersonDto
|
||||||
.Select(d => new DocumentPersonDto
|
{
|
||||||
{
|
Id = d.Id,
|
||||||
Id = d.Id,
|
Name = d.FullName,
|
||||||
Name = d.FullName,
|
Person = d.Person.FullName,
|
||||||
Person = d.Person.FullName,
|
PersonId = d.PersonId
|
||||||
PersonId = d.PersonId
|
})
|
||||||
})
|
.ToListAsync();
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(d => new DocumentPersonDto
|
||||||
{
|
{
|
||||||
Id = d.Id,
|
Id = d.Id,
|
||||||
Alias = d.Alias,
|
Alias = d.Alias,
|
||||||
Name = d.Name,
|
Name = d.Name,
|
||||||
Surname = d.Surname,
|
Surname = d.Surname,
|
||||||
DisplayName = d.DisplayName,
|
DisplayName = d.DisplayName,
|
||||||
PersonId = d.PersonId
|
PersonId = d.PersonId
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -83,6 +80,7 @@ public class DocumentPeopleController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(DocumentPersonDto dto)
|
public async Task UpdateAsync(DocumentPersonDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
DocumentPerson model = await context.DocumentPeople.FindAsync(dto.Id);
|
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)
|
public async Task<int> CreateAsync(DocumentPersonDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new DocumentPerson
|
var model = new DocumentPerson
|
||||||
{
|
{
|
||||||
Alias = dto.Alias,
|
Alias = dto.Alias,
|
||||||
@@ -127,6 +127,7 @@ public class DocumentPeopleController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
DocumentPerson item = await context.DocumentPeople.FindAsync(id);
|
DocumentPerson item = await context.DocumentPeople.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,10 +23,8 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Marechai.Data.Dtos;
|
using Marechai.Data.Dtos;
|
||||||
using Marechai.Database.Models;
|
using Marechai.Database.Models;
|
||||||
@@ -34,7 +32,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,40 +43,39 @@ public class DocumentRolesController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(c => new DocumentRoleDto
|
||||||
{
|
{
|
||||||
Id = c.Id,
|
Id = c.Id,
|
||||||
Name = c.Name,
|
Name = c.Name,
|
||||||
Enabled = c.Enabled
|
Enabled = c.Enabled
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<DocumentRoleDto>> GetEnabledAsync() => await context.DocumentRoles
|
public Task<List<DocumentRoleDto>> GetEnabledAsync() => context.DocumentRoles.Where(c => c.Enabled)
|
||||||
.Where(c => c.Enabled)
|
.OrderBy(c => c.Name)
|
||||||
.OrderBy(c => c.Name)
|
.Select(c => new DocumentRoleDto
|
||||||
.Select(c => new DocumentRoleDto
|
{
|
||||||
{
|
Id = c.Id,
|
||||||
Id = c.Id,
|
Name = c.Name,
|
||||||
Name = c.Name,
|
Enabled = c.Enabled
|
||||||
Enabled = c.Enabled
|
})
|
||||||
})
|
.ToListAsync();
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(c => new DocumentRoleDto
|
||||||
{
|
{
|
||||||
Id = c.Id,
|
Id = c.Id,
|
||||||
Name = c.Name,
|
Name = c.Name,
|
||||||
Enabled = c.Enabled
|
Enabled = c.Enabled
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -53,29 +52,29 @@ public class DocumentScansController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(p => new DocumentScanDto
|
||||||
{
|
{
|
||||||
Author = p.Author,
|
Author = p.Author,
|
||||||
DocumentId = p.Document.Id,
|
DocumentId = p.Document.Id,
|
||||||
ColorSpace = p.ColorSpace,
|
ColorSpace = p.ColorSpace,
|
||||||
Comments = p.Comments,
|
Comments = p.Comments,
|
||||||
CreationDate = p.CreationDate,
|
CreationDate = p.CreationDate,
|
||||||
ExifVersion = p.ExifVersion,
|
ExifVersion = p.ExifVersion,
|
||||||
HorizontalResolution = p.HorizontalResolution,
|
HorizontalResolution = p.HorizontalResolution,
|
||||||
Id = p.Id,
|
Id = p.Id,
|
||||||
ResolutionUnit = p.ResolutionUnit,
|
ResolutionUnit = p.ResolutionUnit,
|
||||||
Page = p.Page,
|
Page = p.Page,
|
||||||
ScannerManufacturer = p.ScannerManufacturer,
|
ScannerManufacturer = p.ScannerManufacturer,
|
||||||
ScannerModel = p.ScannerModel,
|
ScannerModel = p.ScannerModel,
|
||||||
SoftwareUsed = p.SoftwareUsed,
|
SoftwareUsed = p.SoftwareUsed,
|
||||||
Type = p.Type,
|
Type = p.Type,
|
||||||
UploadDate = p.UploadDate,
|
UploadDate = p.UploadDate,
|
||||||
UserId = p.UserId,
|
UserId = p.UserId,
|
||||||
VerticalResolution = p.VerticalResolution,
|
VerticalResolution = p.VerticalResolution,
|
||||||
OriginalExtension = p.OriginalExtension
|
OriginalExtension = p.OriginalExtension
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -84,6 +83,7 @@ public class DocumentScansController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(DocumentScanDto dto)
|
public async Task UpdateAsync(DocumentScanDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
DocumentScan model = await context.DocumentScans.FindAsync(dto.Id);
|
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)
|
public async Task<Guid> CreateAsync(DocumentScanDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return null;
|
if(userId is null) return null;
|
||||||
|
|
||||||
var model = new DocumentScan
|
var model = new DocumentScan
|
||||||
{
|
{
|
||||||
Author = dto.Author,
|
Author = dto.Author,
|
||||||
@@ -149,6 +151,7 @@ public class DocumentScansController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(Guid id)
|
public async Task DeleteAsync(Guid id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
DocumentScan item = await context.DocumentScans.FindAsync(id);
|
DocumentScan item = await context.DocumentScans.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,17 +44,17 @@ public class DocumentsByMachineController(MarechaiContext context) : ControllerB
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.Where(p => p.DocumentId == bookId)
|
||||||
.Select(p => new DocumentByMachineDto
|
.Select(p => new DocumentByMachineDto
|
||||||
{
|
{
|
||||||
Id = p.Id,
|
Id = p.Id,
|
||||||
DocumentId = p.DocumentId,
|
DocumentId = p.DocumentId,
|
||||||
MachineId = p.MachineId,
|
MachineId = p.MachineId,
|
||||||
Machine = p.Machine.Name
|
Machine = p.Machine.Name
|
||||||
})
|
})
|
||||||
.OrderBy(p => p.Machine)
|
.OrderBy(p => p.Machine)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -65,6 +63,7 @@ public class DocumentsByMachineController(MarechaiContext context) : ControllerB
|
|||||||
public async Task DeleteAsync(long id)
|
public async Task DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
DocumentsByMachine item = await context.DocumentsByMachines.FindAsync(id);
|
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)
|
public async Task<long> CreateAsync(int machineId, long bookId)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var item = new DocumentsByMachine
|
var item = new DocumentsByMachine
|
||||||
{
|
{
|
||||||
MachineId = machineId,
|
MachineId = machineId,
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,17 +44,17 @@ public class DocumentsByMachineFamilyController(MarechaiContext context) : Contr
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<DocumentByMachineFamilyDto>> GetByDocument(long bookId) => await context
|
public Task<List<DocumentByMachineFamilyDto>> GetByDocument(long bookId) => context.DocumentsByMachineFamilies
|
||||||
.DocumentsByMachineFamilies.Where(p => p.DocumentId == bookId)
|
.Where(p => p.DocumentId == bookId)
|
||||||
.Select(p => new DocumentByMachineFamilyDto
|
.Select(p => new DocumentByMachineFamilyDto
|
||||||
{
|
{
|
||||||
Id = p.Id,
|
Id = p.Id,
|
||||||
DocumentId = p.DocumentId,
|
DocumentId = p.DocumentId,
|
||||||
MachineFamilyId = p.MachineFamilyId,
|
MachineFamilyId = p.MachineFamilyId,
|
||||||
MachineFamily = p.MachineFamily.Name
|
MachineFamily = p.MachineFamily.Name
|
||||||
})
|
})
|
||||||
.OrderBy(p => p.MachineFamily)
|
.OrderBy(p => p.MachineFamily)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -65,6 +63,7 @@ public class DocumentsByMachineFamilyController(MarechaiContext context) : Contr
|
|||||||
public async Task DeleteAsync(long id)
|
public async Task DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
DocumentsByMachineFamily item = await context.DocumentsByMachineFamilies.FindAsync(id);
|
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)
|
public async Task<long> CreateAsync(int machineFamilyId, long bookId)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var item = new DocumentsByMachineFamily
|
var item = new DocumentsByMachineFamily
|
||||||
{
|
{
|
||||||
MachineFamilyId = machineFamilyId,
|
MachineFamilyId = machineFamilyId,
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,37 +44,37 @@ public class DocumentsController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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.Published)
|
||||||
.ThenBy(b => b.Title)
|
.ThenBy(b => b.Title)
|
||||||
.Select(b => new DocumentDto
|
.Select(b => new DocumentDto
|
||||||
{
|
{
|
||||||
Id = b.Id,
|
Id = b.Id,
|
||||||
Title = b.Title,
|
Title = b.Title,
|
||||||
NativeTitle = b.NativeTitle,
|
NativeTitle = b.NativeTitle,
|
||||||
Published = b.Published,
|
Published = b.Published,
|
||||||
Synopsis = b.Synopsis,
|
Synopsis = b.Synopsis,
|
||||||
CountryId = b.CountryId,
|
CountryId = b.CountryId,
|
||||||
Country = b.Country.Name
|
Country = b.Country.Name
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(b => new DocumentDto
|
||||||
{
|
{
|
||||||
Id = b.Id,
|
Id = b.Id,
|
||||||
Title = b.Title,
|
Title = b.Title,
|
||||||
NativeTitle = b.NativeTitle,
|
NativeTitle = b.NativeTitle,
|
||||||
Published = b.Published,
|
Published = b.Published,
|
||||||
Synopsis = b.Synopsis,
|
Synopsis = b.Synopsis,
|
||||||
CountryId = b.CountryId,
|
CountryId = b.CountryId,
|
||||||
Country = b.Country.Name
|
Country = b.Country.Name
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -85,6 +83,7 @@ public class DocumentsController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(DocumentDto dto)
|
public async Task UpdateAsync(DocumentDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Document model = await context.Documents.FindAsync(dto.Id);
|
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)
|
public async Task<long> CreateAsync(DocumentDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new Document
|
var model = new Document
|
||||||
{
|
{
|
||||||
Title = dto.Title,
|
Title = dto.Title,
|
||||||
@@ -135,6 +136,7 @@ public class DocumentsController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(long id)
|
public async Task DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Document item = await context.Documents.FindAsync(id);
|
Document item = await context.Documents.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,42 +44,42 @@ public class DumpsController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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(d => d.DumpingGroup)
|
||||||
.ThenBy(b => b.Media.Title)
|
.ThenBy(b => b.Media.Title)
|
||||||
.ThenBy(d => d.DumpDate)
|
.ThenBy(d => d.DumpDate)
|
||||||
.Select(d => new DumpDto
|
.Select(d => new DumpDto
|
||||||
{
|
{
|
||||||
Id = d.Id,
|
Id = d.Id,
|
||||||
Dumper = d.Dumper,
|
Dumper = d.Dumper,
|
||||||
UserId = d.UserId,
|
UserId = d.UserId,
|
||||||
DumpingGroup = d.DumpingGroup,
|
DumpingGroup = d.DumpingGroup,
|
||||||
DumpDate = d.DumpDate,
|
DumpDate = d.DumpDate,
|
||||||
UserName = d.User.UserName,
|
UserName = d.User.UserName,
|
||||||
MediaId = d.MediaId,
|
MediaId = d.MediaId,
|
||||||
MediaTitle = d.Media.Title,
|
MediaTitle = d.Media.Title,
|
||||||
MediaDumpId = d.MediaDumpId
|
MediaDumpId = d.MediaDumpId
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(d => new DumpDto
|
||||||
{
|
{
|
||||||
Id = d.Id,
|
Id = d.Id,
|
||||||
Dumper = d.Dumper,
|
Dumper = d.Dumper,
|
||||||
UserId = d.User.Id,
|
UserId = d.User.Id,
|
||||||
DumpingGroup = d.DumpingGroup,
|
DumpingGroup = d.DumpingGroup,
|
||||||
DumpDate = d.DumpDate,
|
DumpDate = d.DumpDate,
|
||||||
UserName = d.User.UserName,
|
UserName = d.User.UserName,
|
||||||
MediaId = d.MediaId,
|
MediaId = d.MediaId,
|
||||||
MediaTitle = d.Media.Title,
|
MediaTitle = d.Media.Title,
|
||||||
MediaDumpId = d.MediaDumpId
|
MediaDumpId = d.MediaDumpId
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -90,6 +88,7 @@ public class DumpsController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(DumpDto dto)
|
public async Task UpdateAsync(DumpDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Dump model = await context.Dumps.FindAsync(dto.Id);
|
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)
|
public async Task<ulong> CreateAsync(DumpDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return null;
|
if(userId is null) return null;
|
||||||
|
|
||||||
var model = new Dump
|
var model = new Dump
|
||||||
{
|
{
|
||||||
Dumper = dto.Dumper,
|
Dumper = dto.Dumper,
|
||||||
@@ -135,6 +136,7 @@ public class DumpsController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(ulong id)
|
public async Task DeleteAsync(ulong id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Dump item = await context.Dumps.FindAsync(id);
|
Dump item = await context.Dumps.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,19 +44,19 @@ public class GpusByMachineController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.Where(g => g.MachineId == machineId)
|
||||||
.Select(g => new GpuByMachineDto
|
.Select(g => new GpuByMachineDto
|
||||||
{
|
{
|
||||||
Id = g.Id,
|
Id = g.Id,
|
||||||
Name = g.Gpu.Name,
|
Name = g.Gpu.Name,
|
||||||
CompanyName = g.Gpu.Company.Name,
|
CompanyName = g.Gpu.Company.Name,
|
||||||
GpuId = g.GpuId,
|
GpuId = g.GpuId,
|
||||||
MachineId = g.MachineId
|
MachineId = g.MachineId
|
||||||
})
|
})
|
||||||
.OrderBy(g => g.CompanyName)
|
.OrderBy(g => g.CompanyName)
|
||||||
.ThenBy(g => g.Name)
|
.ThenBy(g => g.Name)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -67,6 +65,7 @@ public class GpusByMachineController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(long id)
|
public async Task DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
GpusByMachine item = await context.GpusByMachine.FindAsync(id);
|
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)
|
public async Task<long> CreateAsync(int gpuId, int machineId)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var item = new GpusByMachine
|
var item = new GpusByMachine
|
||||||
{
|
{
|
||||||
GpuId = gpuId,
|
GpuId = gpuId,
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,63 +44,63 @@ public class GpusController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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.Name)
|
||||||
.ThenBy(g => g.Introduced)
|
.ThenBy(g => g.Introduced)
|
||||||
.Select(g => new GpuDto
|
.Select(g => new GpuDto
|
||||||
{
|
{
|
||||||
Id = g.Id,
|
Id = g.Id,
|
||||||
Company = g.Company.Name,
|
Company = g.Company.Name,
|
||||||
Introduced = g.Introduced,
|
Introduced = g.Introduced,
|
||||||
ModelCode = g.ModelCode,
|
ModelCode = g.ModelCode,
|
||||||
Name = g.Name
|
Name = g.Name
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.Where(g => g.MachineId == machineId)
|
||||||
.Select(g => g.Gpu)
|
.Select(g => g.Gpu)
|
||||||
.OrderBy(g => g.Company.Name)
|
.OrderBy(g => g.Company.Name)
|
||||||
.ThenBy(g => g.Name)
|
.ThenBy(g => g.Name)
|
||||||
.Select(g => new GpuDto
|
.Select(g => new GpuDto
|
||||||
{
|
{
|
||||||
Id = g.Id,
|
Id = g.Id,
|
||||||
Name = g.Name,
|
Name = g.Name,
|
||||||
Company = g.Company.Name,
|
Company = g.Company.Name,
|
||||||
CompanyId = g.Company.Id,
|
CompanyId = g.Company.Id,
|
||||||
ModelCode = g.ModelCode,
|
ModelCode = g.ModelCode,
|
||||||
Introduced = g.Introduced,
|
Introduced = g.Introduced,
|
||||||
Package = g.Package,
|
Package = g.Package,
|
||||||
Process = g.Process,
|
Process = g.Process,
|
||||||
ProcessNm = g.ProcessNm,
|
ProcessNm = g.ProcessNm,
|
||||||
DieSize = g.DieSize,
|
DieSize = g.DieSize,
|
||||||
Transistors = g.Transistors
|
Transistors = g.Transistors
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(g => new GpuDto
|
||||||
{
|
{
|
||||||
Id = g.Id,
|
Id = g.Id,
|
||||||
Name = g.Name,
|
Name = g.Name,
|
||||||
CompanyId = g.Company.Id,
|
CompanyId = g.Company.Id,
|
||||||
ModelCode = g.ModelCode,
|
ModelCode = g.ModelCode,
|
||||||
Introduced = g.Introduced,
|
Introduced = g.Introduced,
|
||||||
Package = g.Package,
|
Package = g.Package,
|
||||||
Process = g.Process,
|
Process = g.Process,
|
||||||
ProcessNm = g.ProcessNm,
|
ProcessNm = g.ProcessNm,
|
||||||
DieSize = g.DieSize,
|
DieSize = g.DieSize,
|
||||||
Transistors = g.Transistors
|
Transistors = g.Transistors
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -111,6 +109,7 @@ public class GpusController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(GpuDto dto)
|
public async Task UpdateAsync(GpuDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Gpu model = await context.Gpus.FindAsync(dto.Id);
|
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)
|
public async Task<int> CreateAsync(GpuDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new Gpu
|
var model = new Gpu
|
||||||
{
|
{
|
||||||
Name = dto.Name,
|
Name = dto.Name,
|
||||||
@@ -163,6 +164,7 @@ public class GpusController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Gpu item = await context.Gpus.FindAsync(id);
|
Gpu item = await context.Gpus.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -28,13 +28,11 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Marechai.Data.Dtos;
|
|
||||||
using Marechai.Database.Models;
|
using Marechai.Database.Models;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,27 +44,25 @@ public class InstructionSetExtensionsController(MarechaiContext context) : Contr
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<InstructionSetExtension>> GetAsync() => await context.InstructionSetExtensions
|
public Task<List<InstructionSetExtension>> GetAsync() => context.InstructionSetExtensions.OrderBy(e => e.Extension)
|
||||||
.OrderBy(e => e.Extension)
|
.Select(e => new InstructionSetExtension
|
||||||
.Select(e => new InstructionSetExtension
|
{
|
||||||
{
|
Extension = e.Extension,
|
||||||
Extension = e.Extension,
|
Id = e.Id
|
||||||
Id = e.Id
|
})
|
||||||
})
|
.ToListAsync();
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<InstructionSetExtension> GetAsync(int id) => await context.InstructionSetExtensions
|
public Task<InstructionSetExtension> GetAsync(int id) => context.InstructionSetExtensions.Where(e => e.Id == id)
|
||||||
.Where(e => e.Id == id)
|
.Select(e => new InstructionSetExtension
|
||||||
.Select(e => new InstructionSetExtension
|
{
|
||||||
{
|
Extension = e.Extension,
|
||||||
Extension = e.Extension,
|
Id = e.Id
|
||||||
Id = e.Id
|
})
|
||||||
})
|
.FirstOrDefaultAsync();
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -75,6 +71,7 @@ public class InstructionSetExtensionsController(MarechaiContext context) : Contr
|
|||||||
public async Task UpdateAsync(InstructionSetExtension viewModel)
|
public async Task UpdateAsync(InstructionSetExtension viewModel)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
InstructionSetExtension model = await context.InstructionSetExtensions.FindAsync(viewModel.Id);
|
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)
|
public async Task<int> CreateAsync(InstructionSetExtension viewModel)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new InstructionSetExtension
|
var model = new InstructionSetExtension
|
||||||
{
|
{
|
||||||
Extension = viewModel.Extension
|
Extension = viewModel.Extension
|
||||||
@@ -111,6 +110,7 @@ public class InstructionSetExtensionsController(MarechaiContext context) : Contr
|
|||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
InstructionSetExtension item = await context.InstructionSetExtensions.FindAsync(id);
|
InstructionSetExtension item = await context.InstructionSetExtensions.FindAsync(id);
|
||||||
|
|
||||||
@@ -127,6 +127,6 @@ public class InstructionSetExtensionsController(MarechaiContext context) : Contr
|
|||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public bool VerifyUnique(string extension) =>
|
public bool VerifyUnique(string extension) =>
|
||||||
!context.InstructionSetExtensions.Any(i => string.Equals(i.Extension,
|
!context.InstructionSetExtensions.Any(i => string.Equals(i.Extension,
|
||||||
extension,
|
extension,
|
||||||
StringComparison.InvariantCultureIgnoreCase));
|
StringComparison.InvariantCultureIgnoreCase));
|
||||||
}
|
}
|
||||||
@@ -28,13 +28,11 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Marechai.Data.Dtos;
|
|
||||||
using Marechai.Database.Models;
|
using Marechai.Database.Models;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,25 +44,25 @@ public class InstructionSetsController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(e => new InstructionSet
|
||||||
{
|
{
|
||||||
Name = e.Name,
|
Name = e.Name,
|
||||||
Id = e.Id
|
Id = e.Id
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(e => new InstructionSet
|
||||||
{
|
{
|
||||||
Name = e.Name,
|
Name = e.Name,
|
||||||
Id = e.Id
|
Id = e.Id
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -73,6 +71,7 @@ public class InstructionSetsController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(InstructionSet viewModel)
|
public async Task UpdateAsync(InstructionSet viewModel)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
InstructionSet model = await context.InstructionSets.FindAsync(viewModel.Id);
|
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)
|
public async Task<int> CreateAsync(InstructionSet viewModel)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new InstructionSet
|
var model = new InstructionSet
|
||||||
{
|
{
|
||||||
Name = viewModel.Name
|
Name = viewModel.Name
|
||||||
@@ -109,6 +110,7 @@ public class InstructionSetsController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
InstructionSet item = await context.InstructionSets.FindAsync(id);
|
InstructionSet item = await context.InstructionSets.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,18 +23,14 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Marechai.Data.Dtos;
|
|
||||||
using Marechai.Database.Models;
|
using Marechai.Database.Models;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,5 +42,5 @@ public class Iso4217Controller(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Marechai.Data.Dtos;
|
|
||||||
using Marechai.Database.Models;
|
using Marechai.Database.Models;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,34 +43,34 @@ public class LicensesController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(l => new License
|
||||||
{
|
{
|
||||||
FsfApproved = l.FsfApproved,
|
FsfApproved = l.FsfApproved,
|
||||||
Id = l.Id,
|
Id = l.Id,
|
||||||
Link = l.Link,
|
Link = l.Link,
|
||||||
Name = l.Name,
|
Name = l.Name,
|
||||||
OsiApproved = l.OsiApproved,
|
OsiApproved = l.OsiApproved,
|
||||||
SPDX = l.SPDX
|
SPDX = l.SPDX
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(l => new License
|
||||||
{
|
{
|
||||||
FsfApproved = l.FsfApproved,
|
FsfApproved = l.FsfApproved,
|
||||||
Id = l.Id,
|
Id = l.Id,
|
||||||
Link = l.Link,
|
Link = l.Link,
|
||||||
Name = l.Name,
|
Name = l.Name,
|
||||||
OsiApproved = l.OsiApproved,
|
OsiApproved = l.OsiApproved,
|
||||||
SPDX = l.SPDX,
|
SPDX = l.SPDX,
|
||||||
Text = l.Text
|
Text = l.Text
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -82,6 +79,7 @@ public class LicensesController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(License viewModel)
|
public async Task UpdateAsync(License viewModel)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
License model = await context.Licenses.FindAsync(viewModel.Id);
|
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)
|
public async Task<int> CreateAsync(License viewModel)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new License
|
var model = new License
|
||||||
{
|
{
|
||||||
FsfApproved = viewModel.FsfApproved,
|
FsfApproved = viewModel.FsfApproved,
|
||||||
@@ -128,6 +128,7 @@ public class LicensesController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
License item = await context.Licenses.FindAsync(id);
|
License item = await context.Licenses.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,30 +44,29 @@ public class MachineFamiliesController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<MachineFamilyDto>> GetAsync() => await context.MachineFamilies
|
public Task<List<MachineFamilyDto>> GetAsync() => context.MachineFamilies.OrderBy(m => m.Company.Name)
|
||||||
.OrderBy(m => m.Company.Name)
|
.ThenBy(m => m.Name)
|
||||||
.ThenBy(m => m.Name)
|
.Select(m => new MachineFamilyDto
|
||||||
.Select(m => new MachineFamilyDto
|
{
|
||||||
{
|
Id = m.Id,
|
||||||
Id = m.Id,
|
Company = m.Company.Name,
|
||||||
Company = m.Company.Name,
|
Name = m.Name
|
||||||
Name = m.Name
|
})
|
||||||
})
|
.OrderBy(m => m.Name)
|
||||||
.OrderBy(m => m.Name)
|
.ToListAsync();
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(m => new MachineFamilyDto
|
||||||
{
|
{
|
||||||
Id = m.Id,
|
Id = m.Id,
|
||||||
CompanyId = m.CompanyId,
|
CompanyId = m.CompanyId,
|
||||||
Name = m.Name
|
Name = m.Name
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -78,6 +75,7 @@ public class MachineFamiliesController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(MachineFamilyDto dto)
|
public async Task UpdateAsync(MachineFamilyDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
MachineFamily model = await context.MachineFamilies.FindAsync(dto.Id);
|
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)
|
public async Task<int> CreateAsync(MachineFamilyDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new MachineFamily
|
var model = new MachineFamily
|
||||||
{
|
{
|
||||||
Name = dto.Name,
|
Name = dto.Name,
|
||||||
@@ -116,6 +116,7 @@ public class MachineFamiliesController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
MachineFamily item = await context.MachineFamilies.FindAsync(id);
|
MachineFamily item = await context.MachineFamilies.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -53,57 +52,53 @@ public class MachinePhotosController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(p => new MachinePhotoDto
|
||||||
{
|
{
|
||||||
Aperture = p.Aperture,
|
Aperture = p.Aperture,
|
||||||
Author = p.Author,
|
Author = p.Author,
|
||||||
CameraManufacturer = p.CameraManufacturer,
|
CameraManufacturer = p.CameraManufacturer,
|
||||||
CameraModel = p.CameraModel,
|
CameraModel = p.CameraModel,
|
||||||
ColorSpace = p.ColorSpace,
|
ColorSpace = p.ColorSpace,
|
||||||
Comments = p.Comments,
|
Comments = p.Comments,
|
||||||
Contrast = p.Contrast,
|
Contrast = p.Contrast,
|
||||||
CreationDate = p.CreationDate,
|
CreationDate = p.CreationDate,
|
||||||
DigitalZoomRatio = p.DigitalZoomRatio,
|
DigitalZoomRatio = p.DigitalZoomRatio,
|
||||||
ExifVersion = p.ExifVersion,
|
ExifVersion = p.ExifVersion,
|
||||||
ExposureTime = p.ExposureTime,
|
ExposureTime = p.ExposureTime,
|
||||||
ExposureMethod = p.ExposureMethod,
|
ExposureMethod = p.ExposureMethod,
|
||||||
ExposureProgram = p.ExposureProgram,
|
ExposureProgram = p.ExposureProgram,
|
||||||
Flash = p.Flash,
|
Flash = p.Flash,
|
||||||
Focal = p.Focal,
|
Focal = p.Focal,
|
||||||
FocalLength = p.FocalLength,
|
FocalLength = p.FocalLength,
|
||||||
FocalLengthEquivalent =
|
FocalLengthEquivalent = p.FocalLengthEquivalent,
|
||||||
p.FocalLengthEquivalent,
|
HorizontalResolution = p.HorizontalResolution,
|
||||||
HorizontalResolution =
|
Id = p.Id,
|
||||||
p.HorizontalResolution,
|
IsoRating = p.IsoRating,
|
||||||
Id = p.Id,
|
Lens = p.Lens,
|
||||||
IsoRating = p.IsoRating,
|
LicenseId = p.LicenseId,
|
||||||
Lens = p.Lens,
|
LicenseName = p.License.Name,
|
||||||
LicenseId = p.LicenseId,
|
LightSource = p.LightSource,
|
||||||
LicenseName = p.License.Name,
|
MachineCompanyName = p.Machine.Company.Name,
|
||||||
LightSource = p.LightSource,
|
MachineId = p.MachineId,
|
||||||
MachineCompanyName =
|
MachineName = p.Machine.Name,
|
||||||
p.Machine.Company.Name,
|
MeteringMode = p.MeteringMode,
|
||||||
MachineId = p.MachineId,
|
ResolutionUnit = p.ResolutionUnit,
|
||||||
MachineName = p.Machine.Name,
|
Orientation = p.Orientation,
|
||||||
MeteringMode = p.MeteringMode,
|
Saturation = p.Saturation,
|
||||||
ResolutionUnit = p.ResolutionUnit,
|
SceneCaptureType = p.SceneCaptureType,
|
||||||
Orientation = p.Orientation,
|
SensingMethod = p.SensingMethod,
|
||||||
Saturation = p.Saturation,
|
Sharpness = p.Sharpness,
|
||||||
SceneCaptureType = p.SceneCaptureType,
|
SoftwareUsed = p.SoftwareUsed,
|
||||||
SensingMethod = p.SensingMethod,
|
Source = p.Source,
|
||||||
Sharpness = p.Sharpness,
|
SubjectDistanceRange = p.SubjectDistanceRange,
|
||||||
SoftwareUsed = p.SoftwareUsed,
|
UploadDate = p.UploadDate,
|
||||||
Source = p.Source,
|
UserId = p.UserId,
|
||||||
SubjectDistanceRange =
|
VerticalResolution = p.VerticalResolution,
|
||||||
p.SubjectDistanceRange,
|
WhiteBalance = p.WhiteBalance,
|
||||||
UploadDate = p.UploadDate,
|
OriginalExtension = p.OriginalExtension
|
||||||
UserId = p.UserId,
|
})
|
||||||
VerticalResolution = p.VerticalResolution,
|
.FirstOrDefaultAsync();
|
||||||
WhiteBalance = p.WhiteBalance,
|
|
||||||
OriginalExtension = p.OriginalExtension
|
|
||||||
})
|
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -112,6 +107,7 @@ public class MachinePhotosController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(MachinePhotoDto dto)
|
public async Task UpdateAsync(MachinePhotoDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
MachinePhoto model = await context.MachinePhotos.FindAsync(dto.Id);
|
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)
|
public async Task<Guid> CreateAsync(MachinePhotoDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return null;
|
if(userId is null) return null;
|
||||||
|
|
||||||
var model = new MachinePhoto
|
var model = new MachinePhoto
|
||||||
{
|
{
|
||||||
Aperture = dto.Aperture,
|
Aperture = dto.Aperture,
|
||||||
|
|||||||
@@ -40,48 +40,51 @@ namespace Marechai.Server.Controllers;
|
|||||||
|
|
||||||
[Route("/machines")]
|
[Route("/machines")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class MachinesController(MarechaiContext context,
|
public class MachinesController
|
||||||
|
(
|
||||||
|
MarechaiContext context,
|
||||||
IStringLocalizer<MachinesService> localizer,
|
IStringLocalizer<MachinesService> localizer,
|
||||||
GpusService gpusService,
|
GpusService gpusService,
|
||||||
ProcessorsService processorsService,
|
ProcessorsService processorsService,
|
||||||
SoundSynthsService soundSynthsService) : ControllerBase
|
SoundSynthsService soundSynthsService
|
||||||
|
) : ControllerBase
|
||||||
{
|
{
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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.Name)
|
||||||
.ThenBy(m => m.Family.Name)
|
.ThenBy(m => m.Family.Name)
|
||||||
.Select(m => new MachineDto
|
.Select(m => new MachineDto
|
||||||
{
|
{
|
||||||
Id = m.Id,
|
Id = m.Id,
|
||||||
Company = m.Company.Name,
|
Company = m.Company.Name,
|
||||||
Name = m.Name,
|
Name = m.Name,
|
||||||
Model = m.Model,
|
Model = m.Model,
|
||||||
Introduced = m.Introduced,
|
Introduced = m.Introduced,
|
||||||
Type = m.Type,
|
Type = m.Type,
|
||||||
Family = m.Family.Name
|
Family = m.Family.Name
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(m => new MachineDto
|
||||||
{
|
{
|
||||||
Id = m.Id,
|
Id = m.Id,
|
||||||
Company = m.Company.Name,
|
Company = m.Company.Name,
|
||||||
CompanyId = m.CompanyId,
|
CompanyId = m.CompanyId,
|
||||||
Name = m.Name,
|
Name = m.Name,
|
||||||
Model = m.Model,
|
Model = m.Model,
|
||||||
Introduced = m.Introduced,
|
Introduced = m.Introduced,
|
||||||
Type = m.Type,
|
Type = m.Type,
|
||||||
FamilyId = m.FamilyId
|
FamilyId = m.FamilyId
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -90,6 +93,7 @@ public class MachinesController(MarechaiContext context,
|
|||||||
public async Task UpdateAsync(MachineDto dto)
|
public async Task UpdateAsync(MachineDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Machine model = await context.Machines.FindAsync(dto.Id);
|
Machine model = await context.Machines.FindAsync(dto.Id);
|
||||||
|
|
||||||
@@ -136,7 +140,9 @@ public class MachinesController(MarechaiContext context,
|
|||||||
public async Task<int> CreateAsync(MachineDto dto)
|
public async Task<int> CreateAsync(MachineDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new Machine
|
var model = new Machine
|
||||||
{
|
{
|
||||||
CompanyId = dto.CompanyId,
|
CompanyId = dto.CompanyId,
|
||||||
@@ -209,9 +215,7 @@ public class MachinesController(MarechaiContext context,
|
|||||||
IQueryable<CompanyLogo> logos = context.CompanyLogos.Where(l => l.CompanyId == company.Id);
|
IQueryable<CompanyLogo> logos = context.CompanyLogos.Where(l => l.CompanyId == company.Id);
|
||||||
|
|
||||||
if(model.Introduced.HasValue)
|
if(model.Introduced.HasValue)
|
||||||
{
|
|
||||||
model.CompanyLogo = (await logos.FirstOrDefaultAsync(l => l.Year >= model.Introduced.Value.Year))?.Guid;
|
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;
|
if(model.CompanyLogo is null && logos.Any()) model.CompanyLogo = (await logos.FirstAsync())?.Guid;
|
||||||
}
|
}
|
||||||
@@ -227,27 +231,27 @@ public class MachinesController(MarechaiContext context,
|
|||||||
model.Gpus = await gpusService.GetByMachineAsync(machine.Id);
|
model.Gpus = await gpusService.GetByMachineAsync(machine.Id);
|
||||||
|
|
||||||
model.Memory = await context.MemoryByMachine.Where(m => m.MachineId == machine.Id)
|
model.Memory = await context.MemoryByMachine.Where(m => m.MachineId == machine.Id)
|
||||||
.Select(m => new MemoryDto
|
.Select(m => new MemoryDto
|
||||||
{
|
{
|
||||||
Type = m.Type,
|
Type = m.Type,
|
||||||
Usage = m.Usage,
|
Usage = m.Usage,
|
||||||
Size = m.Size,
|
Size = m.Size,
|
||||||
Speed = m.Speed
|
Speed = m.Speed
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
model.Processors = await processorsService.GetByMachineAsync(machine.Id);
|
model.Processors = await processorsService.GetByMachineAsync(machine.Id);
|
||||||
|
|
||||||
model.SoundSynthesizers = await soundSynthsService.GetByMachineAsync(machine.Id);
|
model.SoundSynthesizers = await soundSynthsService.GetByMachineAsync(machine.Id);
|
||||||
|
|
||||||
model.Storage = await context.StorageByMachine.Where(s => s.MachineId == machine.Id)
|
model.Storage = await context.StorageByMachine.Where(s => s.MachineId == machine.Id)
|
||||||
.Select(s => new StorageDto
|
.Select(s => new StorageDto
|
||||||
{
|
{
|
||||||
Type = s.Type,
|
Type = s.Type,
|
||||||
Interface = s.Interface,
|
Interface = s.Interface,
|
||||||
Capacity = s.Capacity
|
Capacity = s.Capacity
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
@@ -259,6 +263,7 @@ public class MachinesController(MarechaiContext context,
|
|||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Machine item = await context.Machines.FindAsync(id);
|
Machine item = await context.Machines.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,42 +44,41 @@ public class MagazineIssuesController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<MagazineIssueDto>> GetAsync() => await context.MagazineIssues
|
public Task<List<MagazineIssueDto>> GetAsync() => context.MagazineIssues.OrderBy(b => b.Magazine.Title)
|
||||||
.OrderBy(b => b.Magazine.Title)
|
.ThenBy(b => b.Published)
|
||||||
.ThenBy(b => b.Published)
|
.ThenBy(b => b.Caption)
|
||||||
.ThenBy(b => b.Caption)
|
.Select(b => new MagazineIssueDto
|
||||||
.Select(b => new MagazineIssueDto
|
{
|
||||||
{
|
Id = b.Id,
|
||||||
Id = b.Id,
|
MagazineId = b.MagazineId,
|
||||||
MagazineId = b.MagazineId,
|
MagazineTitle = b.Magazine.Title,
|
||||||
MagazineTitle = b.Magazine.Title,
|
Caption = b.Caption,
|
||||||
Caption = b.Caption,
|
NativeCaption = b.NativeCaption,
|
||||||
NativeCaption = b.NativeCaption,
|
Published = b.Published,
|
||||||
Published = b.Published,
|
ProductCode = b.ProductCode,
|
||||||
ProductCode = b.ProductCode,
|
Pages = b.Pages,
|
||||||
Pages = b.Pages,
|
IssueNumber = b.IssueNumber
|
||||||
IssueNumber = b.IssueNumber
|
})
|
||||||
})
|
.ToListAsync();
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(b => new MagazineIssueDto
|
||||||
{
|
{
|
||||||
Id = b.Id,
|
Id = b.Id,
|
||||||
MagazineId = b.MagazineId,
|
MagazineId = b.MagazineId,
|
||||||
MagazineTitle = b.Magazine.Title,
|
MagazineTitle = b.Magazine.Title,
|
||||||
Caption = b.Caption,
|
Caption = b.Caption,
|
||||||
NativeCaption = b.NativeCaption,
|
NativeCaption = b.NativeCaption,
|
||||||
Published = b.Published,
|
Published = b.Published,
|
||||||
ProductCode = b.ProductCode,
|
ProductCode = b.ProductCode,
|
||||||
Pages = b.Pages,
|
Pages = b.Pages,
|
||||||
IssueNumber = b.IssueNumber
|
IssueNumber = b.IssueNumber
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -90,6 +87,7 @@ public class MagazineIssuesController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(MagazineIssueDto dto)
|
public async Task UpdateAsync(MagazineIssueDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
MagazineIssue model = await context.MagazineIssues.FindAsync(dto.Id);
|
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)
|
public async Task<long> CreateAsync(MagazineIssueDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new MagazineIssue
|
var model = new MagazineIssue
|
||||||
{
|
{
|
||||||
MagazineId = dto.MagazineId,
|
MagazineId = dto.MagazineId,
|
||||||
@@ -137,6 +137,7 @@ public class MagazineIssuesController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(long id)
|
public async Task DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
MagazineIssue item = await context.MagazineIssues.FindAsync(id);
|
MagazineIssue item = await context.MagazineIssues.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -53,29 +52,29 @@ public class MagazineScansController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(p => new MagazineScanDto
|
||||||
{
|
{
|
||||||
Author = p.Author,
|
Author = p.Author,
|
||||||
MagazineId = p.Magazine.Id,
|
MagazineId = p.Magazine.Id,
|
||||||
ColorSpace = p.ColorSpace,
|
ColorSpace = p.ColorSpace,
|
||||||
Comments = p.Comments,
|
Comments = p.Comments,
|
||||||
CreationDate = p.CreationDate,
|
CreationDate = p.CreationDate,
|
||||||
ExifVersion = p.ExifVersion,
|
ExifVersion = p.ExifVersion,
|
||||||
HorizontalResolution = p.HorizontalResolution,
|
HorizontalResolution = p.HorizontalResolution,
|
||||||
Id = p.Id,
|
Id = p.Id,
|
||||||
ResolutionUnit = p.ResolutionUnit,
|
ResolutionUnit = p.ResolutionUnit,
|
||||||
Page = p.Page,
|
Page = p.Page,
|
||||||
ScannerManufacturer = p.ScannerManufacturer,
|
ScannerManufacturer = p.ScannerManufacturer,
|
||||||
ScannerModel = p.ScannerModel,
|
ScannerModel = p.ScannerModel,
|
||||||
SoftwareUsed = p.SoftwareUsed,
|
SoftwareUsed = p.SoftwareUsed,
|
||||||
Type = p.Type,
|
Type = p.Type,
|
||||||
UploadDate = p.UploadDate,
|
UploadDate = p.UploadDate,
|
||||||
UserId = p.UserId,
|
UserId = p.UserId,
|
||||||
VerticalResolution = p.VerticalResolution,
|
VerticalResolution = p.VerticalResolution,
|
||||||
OriginalExtension = p.OriginalExtension
|
OriginalExtension = p.OriginalExtension
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -84,6 +83,7 @@ public class MagazineScansController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(MagazineScanDto dto)
|
public async Task UpdateAsync(MagazineScanDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
MagazineScan model = await context.MagazineScans.FindAsync(dto.Id);
|
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)
|
public async Task<Guid> CreateAsync(MagazineScanDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return null;
|
if(userId is null) return null;
|
||||||
|
|
||||||
var model = new MagazineScan
|
var model = new MagazineScan
|
||||||
{
|
{
|
||||||
Author = dto.Author,
|
Author = dto.Author,
|
||||||
@@ -149,6 +151,7 @@ public class MagazineScansController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(Guid id)
|
public async Task DeleteAsync(Guid id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
MagazineScan item = await context.MagazineScans.FindAsync(id);
|
MagazineScan item = await context.MagazineScans.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,17 +44,17 @@ public class MagazinesByMachineController(MarechaiContext context) : ControllerB
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.Where(p => p.MagazineId == bookId)
|
||||||
.Select(p => new MagazineByMachineDto
|
.Select(p => new MagazineByMachineDto
|
||||||
{
|
{
|
||||||
Id = p.Id,
|
Id = p.Id,
|
||||||
MagazineId = p.MagazineId,
|
MagazineId = p.MagazineId,
|
||||||
MachineId = p.MachineId,
|
MachineId = p.MachineId,
|
||||||
Machine = p.Machine.Name
|
Machine = p.Machine.Name
|
||||||
})
|
})
|
||||||
.OrderBy(p => p.Machine)
|
.OrderBy(p => p.Machine)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -65,6 +63,7 @@ public class MagazinesByMachineController(MarechaiContext context) : ControllerB
|
|||||||
public async Task DeleteAsync(long id)
|
public async Task DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
MagazinesByMachine item = await context.MagazinesByMachines.FindAsync(id);
|
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)
|
public async Task<long> CreateAsync(int machineId, long bookId)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var item = new MagazinesByMachine
|
var item = new MagazinesByMachine
|
||||||
{
|
{
|
||||||
MachineId = machineId,
|
MachineId = machineId,
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,17 +44,17 @@ public class MagazinesByMachineFamilyController(MarechaiContext context) : Contr
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<MagazineByMachineFamilyDto>> GetByMagazine(long bookId) => await context
|
public Task<List<MagazineByMachineFamilyDto>> GetByMagazine(long bookId) => context.MagazinesByMachinesFamilies
|
||||||
.MagazinesByMachinesFamilies.Where(p => p.MagazineId == bookId)
|
.Where(p => p.MagazineId == bookId)
|
||||||
.Select(p => new MagazineByMachineFamilyDto
|
.Select(p => new MagazineByMachineFamilyDto
|
||||||
{
|
{
|
||||||
Id = p.Id,
|
Id = p.Id,
|
||||||
MagazineId = p.MagazineId,
|
MagazineId = p.MagazineId,
|
||||||
MachineFamilyId = p.MachineFamilyId,
|
MachineFamilyId = p.MachineFamilyId,
|
||||||
MachineFamily = p.MachineFamily.Name
|
MachineFamily = p.MachineFamily.Name
|
||||||
})
|
})
|
||||||
.OrderBy(p => p.MachineFamily)
|
.OrderBy(p => p.MachineFamily)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -65,6 +63,7 @@ public class MagazinesByMachineFamilyController(MarechaiContext context) : Contr
|
|||||||
public async Task DeleteAsync(long id)
|
public async Task DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
MagazinesByMachineFamily item = await context.MagazinesByMachinesFamilies.FindAsync(id);
|
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)
|
public async Task<long> CreateAsync(int machineFamilyId, long bookId)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var item = new MagazinesByMachineFamily
|
var item = new MagazinesByMachineFamily
|
||||||
{
|
{
|
||||||
MachineFamilyId = machineFamilyId,
|
MachineFamilyId = machineFamilyId,
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,52 +44,52 @@ public class MagazinesController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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.FirstPublication)
|
||||||
.ThenBy(b => b.Title)
|
.ThenBy(b => b.Title)
|
||||||
.Select(b => new MagazineDto
|
.Select(b => new MagazineDto
|
||||||
{
|
{
|
||||||
Id = b.Id,
|
Id = b.Id,
|
||||||
Title = b.Title,
|
Title = b.Title,
|
||||||
NativeTitle = b.NativeTitle,
|
NativeTitle = b.NativeTitle,
|
||||||
FirstPublication = b.FirstPublication,
|
FirstPublication = b.FirstPublication,
|
||||||
Synopsis = b.Synopsis,
|
Synopsis = b.Synopsis,
|
||||||
Issn = b.Issn,
|
Issn = b.Issn,
|
||||||
CountryId = b.CountryId,
|
CountryId = b.CountryId,
|
||||||
Country = b.Country.Name
|
Country = b.Country.Name
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.ThenBy(b => b.FirstPublication)
|
||||||
.Select(b => new MagazineDto
|
.Select(b => new MagazineDto
|
||||||
{
|
{
|
||||||
Id = b.Id,
|
Id = b.Id,
|
||||||
Title = $"{b.Title} ({b.Country.Name}"
|
Title = $"{b.Title} ({b.Country.Name}"
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(b => new MagazineDto
|
||||||
{
|
{
|
||||||
Id = b.Id,
|
Id = b.Id,
|
||||||
Title = b.Title,
|
Title = b.Title,
|
||||||
NativeTitle = b.NativeTitle,
|
NativeTitle = b.NativeTitle,
|
||||||
FirstPublication = b.FirstPublication,
|
FirstPublication = b.FirstPublication,
|
||||||
Synopsis = b.Synopsis,
|
Synopsis = b.Synopsis,
|
||||||
Issn = b.Issn,
|
Issn = b.Issn,
|
||||||
CountryId = b.CountryId,
|
CountryId = b.CountryId,
|
||||||
Country = b.Country.Name
|
Country = b.Country.Name
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -100,6 +98,7 @@ public class MagazinesController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(MagazineDto dto)
|
public async Task UpdateAsync(MagazineDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Magazine model = await context.Magazines.FindAsync(dto.Id);
|
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)
|
public async Task<long> CreateAsync(MagazineDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new Magazine
|
var model = new Magazine
|
||||||
{
|
{
|
||||||
Title = dto.Title,
|
Title = dto.Title,
|
||||||
@@ -152,6 +153,7 @@ public class MagazinesController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(long id)
|
public async Task DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Magazine item = await context.Magazines.FindAsync(id);
|
Magazine item = await context.Magazines.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,85 +44,85 @@ public class MediaController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(d => new MediaDto
|
||||||
{
|
{
|
||||||
Id = d.Id,
|
Id = d.Id,
|
||||||
Title = d.Title,
|
Title = d.Title,
|
||||||
Sequence = d.Sequence,
|
Sequence = d.Sequence,
|
||||||
LastSequence = d.LastSequence,
|
LastSequence = d.LastSequence,
|
||||||
Type = d.Type,
|
Type = d.Type,
|
||||||
WriteOffset = d.WriteOffset,
|
WriteOffset = d.WriteOffset,
|
||||||
Sides = d.Sides,
|
Sides = d.Sides,
|
||||||
Layers = d.Layers,
|
Layers = d.Layers,
|
||||||
Sessions = d.Sessions,
|
Sessions = d.Sessions,
|
||||||
Tracks = d.Tracks,
|
Tracks = d.Tracks,
|
||||||
Sectors = d.Sectors,
|
Sectors = d.Sectors,
|
||||||
Size = d.Size,
|
Size = d.Size,
|
||||||
CopyProtection = d.CopyProtection,
|
CopyProtection = d.CopyProtection,
|
||||||
PartNumber = d.PartNumber,
|
PartNumber = d.PartNumber,
|
||||||
SerialNumber = d.SerialNumber,
|
SerialNumber = d.SerialNumber,
|
||||||
Barcode = d.Barcode,
|
Barcode = d.Barcode,
|
||||||
CatalogueNumber = d.CatalogueNumber,
|
CatalogueNumber = d.CatalogueNumber,
|
||||||
Manufacturer = d.Manufacturer,
|
Manufacturer = d.Manufacturer,
|
||||||
Model = d.Model,
|
Model = d.Model,
|
||||||
Revision = d.Revision,
|
Revision = d.Revision,
|
||||||
Firmware = d.Firmware,
|
Firmware = d.Firmware,
|
||||||
PhysicalBlockSize = d.PhysicalBlockSize,
|
PhysicalBlockSize = d.PhysicalBlockSize,
|
||||||
LogicalBlockSize = d.LogicalBlockSize,
|
LogicalBlockSize = d.LogicalBlockSize,
|
||||||
BlockSizes = d.BlockSizes,
|
BlockSizes = d.BlockSizes,
|
||||||
StorageInterface = d.StorageInterface,
|
StorageInterface = d.StorageInterface,
|
||||||
TableOfContents = d.TableOfContents
|
TableOfContents = d.TableOfContents
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(d => new MediaDto
|
||||||
{
|
{
|
||||||
Id = d.Id,
|
Id = d.Id,
|
||||||
Title = d.Title
|
Title = d.Title
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(d => new MediaDto
|
||||||
{
|
{
|
||||||
Id = d.Id,
|
Id = d.Id,
|
||||||
Title = d.Title,
|
Title = d.Title,
|
||||||
Sequence = d.Sequence,
|
Sequence = d.Sequence,
|
||||||
LastSequence = d.LastSequence,
|
LastSequence = d.LastSequence,
|
||||||
Type = d.Type,
|
Type = d.Type,
|
||||||
WriteOffset = d.WriteOffset,
|
WriteOffset = d.WriteOffset,
|
||||||
Sides = d.Sides,
|
Sides = d.Sides,
|
||||||
Layers = d.Layers,
|
Layers = d.Layers,
|
||||||
Sessions = d.Sessions,
|
Sessions = d.Sessions,
|
||||||
Tracks = d.Tracks,
|
Tracks = d.Tracks,
|
||||||
Sectors = d.Sectors,
|
Sectors = d.Sectors,
|
||||||
Size = d.Size,
|
Size = d.Size,
|
||||||
CopyProtection = d.CopyProtection,
|
CopyProtection = d.CopyProtection,
|
||||||
PartNumber = d.PartNumber,
|
PartNumber = d.PartNumber,
|
||||||
SerialNumber = d.SerialNumber,
|
SerialNumber = d.SerialNumber,
|
||||||
Barcode = d.Barcode,
|
Barcode = d.Barcode,
|
||||||
CatalogueNumber = d.CatalogueNumber,
|
CatalogueNumber = d.CatalogueNumber,
|
||||||
Manufacturer = d.Manufacturer,
|
Manufacturer = d.Manufacturer,
|
||||||
Model = d.Model,
|
Model = d.Model,
|
||||||
Revision = d.Revision,
|
Revision = d.Revision,
|
||||||
Firmware = d.Firmware,
|
Firmware = d.Firmware,
|
||||||
PhysicalBlockSize = d.PhysicalBlockSize,
|
PhysicalBlockSize = d.PhysicalBlockSize,
|
||||||
LogicalBlockSize = d.LogicalBlockSize,
|
LogicalBlockSize = d.LogicalBlockSize,
|
||||||
BlockSizes = d.BlockSizes,
|
BlockSizes = d.BlockSizes,
|
||||||
StorageInterface = d.StorageInterface,
|
StorageInterface = d.StorageInterface,
|
||||||
TableOfContents = d.TableOfContents
|
TableOfContents = d.TableOfContents
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -133,6 +131,7 @@ public class MediaController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(MediaDto dto)
|
public async Task UpdateAsync(MediaDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Media model = await context.Media.FindAsync(dto.Id);
|
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)
|
public async Task<ulong> CreateAsync(MediaDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return null;
|
if(userId is null) return null;
|
||||||
|
|
||||||
var model = new Media
|
var model = new Media
|
||||||
{
|
{
|
||||||
Title = dto.Title,
|
Title = dto.Title,
|
||||||
@@ -216,6 +217,7 @@ public class MediaController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(ulong id)
|
public async Task DeleteAsync(ulong id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Media item = await context.Media.FindAsync(id);
|
Media item = await context.Media.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,22 +44,22 @@ public class MemoriesByMachineController(MarechaiContext context) : ControllerBa
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.Where(m => m.MachineId == machineId)
|
||||||
.Select(m => new MemoryByMachineDto
|
.Select(m => new MemoryByMachineDto
|
||||||
{
|
{
|
||||||
Id = m.Id,
|
Id = m.Id,
|
||||||
Type = m.Type,
|
Type = m.Type,
|
||||||
Usage = m.Usage,
|
Usage = m.Usage,
|
||||||
Size = m.Size,
|
Size = m.Size,
|
||||||
Speed = m.Speed,
|
Speed = m.Speed,
|
||||||
MachineId = m.MachineId
|
MachineId = m.MachineId
|
||||||
})
|
})
|
||||||
.OrderBy(m => m.Type)
|
.OrderBy(m => m.Type)
|
||||||
.ThenBy(m => m.Usage)
|
.ThenBy(m => m.Usage)
|
||||||
.ThenBy(m => m.Size)
|
.ThenBy(m => m.Size)
|
||||||
.ThenBy(m => m.Speed)
|
.ThenBy(m => m.Speed)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -70,6 +68,7 @@ public class MemoriesByMachineController(MarechaiContext context) : ControllerBa
|
|||||||
public async Task DeleteAsync(long id)
|
public async Task DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
MemoryByMachine item = await context.MemoryByMachine.FindAsync(id);
|
MemoryByMachine item = await context.MemoryByMachine.FindAsync(id);
|
||||||
|
|
||||||
@@ -84,10 +83,12 @@ public class MemoriesByMachineController(MarechaiContext context) : ControllerBa
|
|||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<long> CreateAsync(int machineId, MemoryType type, MemoryUsage usage, long? size, double? speed)
|
public async Task<long> CreateAsync(int machineId, MemoryType type, MemoryUsage usage, long? size, double? speed)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var item = new MemoryByMachine
|
var item = new MemoryByMachine
|
||||||
{
|
{
|
||||||
MachineId = machineId,
|
MachineId = machineId,
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -46,15 +45,15 @@ public class NewsController(MarechaiContext context, IStringLocalizer<NewsServic
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(n => new NewsDto
|
||||||
{
|
{
|
||||||
Id = n.Id,
|
Id = n.Id,
|
||||||
Timestamp = n.Date,
|
Timestamp = n.Date,
|
||||||
Type = n.Type,
|
Type = n.Type,
|
||||||
AffectedId = n.AddedId
|
AffectedId = n.AddedId
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
@@ -74,72 +73,72 @@ public class NewsController(MarechaiContext context, IStringLocalizer<NewsServic
|
|||||||
{
|
{
|
||||||
case NewsType.NewComputerInDb:
|
case NewsType.NewComputerInDb:
|
||||||
news.Add(new NewsDto(@new.AddedId,
|
news.Add(new NewsDto(@new.AddedId,
|
||||||
localizer["New computer in database"],
|
localizer["New computer in database"],
|
||||||
@new.Date,
|
@new.Date,
|
||||||
"machine",
|
"machine",
|
||||||
$"{machine.Company.Name} {machine.Name}"));
|
$"{machine.Company.Name} {machine.Name}"));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NewsType.NewConsoleInDb:
|
case NewsType.NewConsoleInDb:
|
||||||
news.Add(new NewsDto(@new.AddedId,
|
news.Add(new NewsDto(@new.AddedId,
|
||||||
localizer["New console in database"],
|
localizer["New console in database"],
|
||||||
@new.Date,
|
@new.Date,
|
||||||
"machine",
|
"machine",
|
||||||
$"{machine.Company.Name} {machine.Name}"));
|
$"{machine.Company.Name} {machine.Name}"));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NewsType.NewComputerInCollection:
|
case NewsType.NewComputerInCollection:
|
||||||
news.Add(new NewsDto(@new.AddedId,
|
news.Add(new NewsDto(@new.AddedId,
|
||||||
localizer["New computer in collection"],
|
localizer["New computer in collection"],
|
||||||
@new.Date,
|
@new.Date,
|
||||||
"machine",
|
"machine",
|
||||||
$"{machine.Company.Name} {machine.Name}"));
|
$"{machine.Company.Name} {machine.Name}"));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NewsType.NewConsoleInCollection:
|
case NewsType.NewConsoleInCollection:
|
||||||
news.Add(new NewsDto(@new.AddedId,
|
news.Add(new NewsDto(@new.AddedId,
|
||||||
localizer["New console in collection"],
|
localizer["New console in collection"],
|
||||||
@new.Date,
|
@new.Date,
|
||||||
"machine",
|
"machine",
|
||||||
$"{machine.Company.Name} {machine.Name}"));
|
$"{machine.Company.Name} {machine.Name}"));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NewsType.UpdatedComputerInDb:
|
case NewsType.UpdatedComputerInDb:
|
||||||
news.Add(new NewsDto(@new.AddedId,
|
news.Add(new NewsDto(@new.AddedId,
|
||||||
localizer["Updated computer in database"],
|
localizer["Updated computer in database"],
|
||||||
@new.Date,
|
@new.Date,
|
||||||
"machine",
|
"machine",
|
||||||
$"{machine.Company.Name} {machine.Name}"));
|
$"{machine.Company.Name} {machine.Name}"));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NewsType.UpdatedConsoleInDb:
|
case NewsType.UpdatedConsoleInDb:
|
||||||
news.Add(new NewsDto(@new.AddedId,
|
news.Add(new NewsDto(@new.AddedId,
|
||||||
localizer["Updated console in database"],
|
localizer["Updated console in database"],
|
||||||
@new.Date,
|
@new.Date,
|
||||||
"machine",
|
"machine",
|
||||||
$"{machine.Company.Name} {machine.Name}"));
|
$"{machine.Company.Name} {machine.Name}"));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NewsType.UpdatedComputerInCollection:
|
case NewsType.UpdatedComputerInCollection:
|
||||||
news.Add(new NewsDto(@new.AddedId,
|
news.Add(new NewsDto(@new.AddedId,
|
||||||
localizer["Updated computer in collection"],
|
localizer["Updated computer in collection"],
|
||||||
@new.Date,
|
@new.Date,
|
||||||
"machine",
|
"machine",
|
||||||
$"{machine.Company.Name} {machine.Name}"));
|
$"{machine.Company.Name} {machine.Name}"));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NewsType.UpdatedConsoleInCollection:
|
case NewsType.UpdatedConsoleInCollection:
|
||||||
news.Add(new NewsDto(@new.AddedId,
|
news.Add(new NewsDto(@new.AddedId,
|
||||||
localizer["Updated console in collection"],
|
localizer["Updated console in collection"],
|
||||||
@new.Date,
|
@new.Date,
|
||||||
"machine",
|
"machine",
|
||||||
$"{machine.Company.Name} {machine.Name}"));
|
$"{machine.Company.Name} {machine.Name}"));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -162,6 +161,7 @@ public class NewsController(MarechaiContext context, IStringLocalizer<NewsServic
|
|||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
News item = await context.News.FindAsync(id);
|
News item = await context.News.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,48 +44,48 @@ public class PeopleController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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.Alias)
|
||||||
.ThenBy(p => p.Name)
|
.ThenBy(p => p.Name)
|
||||||
.ThenBy(p => p.Surname)
|
.ThenBy(p => p.Surname)
|
||||||
.Select(p => new PersonDto
|
.Select(p => new PersonDto
|
||||||
{
|
{
|
||||||
Id = p.Id,
|
Id = p.Id,
|
||||||
Name = p.Name,
|
Name = p.Name,
|
||||||
Surname = p.Surname,
|
Surname = p.Surname,
|
||||||
CountryOfBirth = p.CountryOfBirth.Name,
|
CountryOfBirth = p.CountryOfBirth.Name,
|
||||||
BirthDate = p.BirthDate,
|
BirthDate = p.BirthDate,
|
||||||
DeathDate = p.DeathDate,
|
DeathDate = p.DeathDate,
|
||||||
Webpage = p.Webpage,
|
Webpage = p.Webpage,
|
||||||
Twitter = p.Twitter,
|
Twitter = p.Twitter,
|
||||||
Facebook = p.Facebook,
|
Facebook = p.Facebook,
|
||||||
Photo = p.Photo,
|
Photo = p.Photo,
|
||||||
Alias = p.Alias,
|
Alias = p.Alias,
|
||||||
DisplayName = p.DisplayName
|
DisplayName = p.DisplayName
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(p => new PersonDto
|
||||||
{
|
{
|
||||||
Id = p.Id,
|
Id = p.Id,
|
||||||
Name = p.Name,
|
Name = p.Name,
|
||||||
Surname = p.Surname,
|
Surname = p.Surname,
|
||||||
CountryOfBirthId = p.CountryOfBirthId,
|
CountryOfBirthId = p.CountryOfBirthId,
|
||||||
BirthDate = p.BirthDate,
|
BirthDate = p.BirthDate,
|
||||||
DeathDate = p.DeathDate,
|
DeathDate = p.DeathDate,
|
||||||
Webpage = p.Webpage,
|
Webpage = p.Webpage,
|
||||||
Twitter = p.Twitter,
|
Twitter = p.Twitter,
|
||||||
Facebook = p.Facebook,
|
Facebook = p.Facebook,
|
||||||
Photo = p.Photo,
|
Photo = p.Photo,
|
||||||
Alias = p.Alias,
|
Alias = p.Alias,
|
||||||
DisplayName = p.DisplayName
|
DisplayName = p.DisplayName
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -96,6 +94,7 @@ public class PeopleController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(PersonDto dto)
|
public async Task UpdateAsync(PersonDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Person model = await context.People.FindAsync(dto.Id);
|
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)
|
public async Task<int> CreateAsync(PersonDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new Person
|
var model = new Person
|
||||||
{
|
{
|
||||||
Name = dto.Name,
|
Name = dto.Name,
|
||||||
@@ -152,6 +153,7 @@ public class PeopleController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Person item = await context.People.FindAsync(id);
|
Person item = await context.People.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,20 +44,20 @@ public class ProcessorsByMachineController(MarechaiContext context) : Controller
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<ProcessorByMachineDto>> GetByMachine(int machineId) => await context
|
public Task<List<ProcessorByMachineDto>> GetByMachine(int machineId) => context.ProcessorsByMachine
|
||||||
.ProcessorsByMachine.Where(p => p.MachineId == machineId)
|
.Where(p => p.MachineId == machineId)
|
||||||
.Select(p => new ProcessorByMachineDto
|
.Select(p => new ProcessorByMachineDto
|
||||||
{
|
{
|
||||||
Id = p.Id,
|
Id = p.Id,
|
||||||
Name = p.Processor.Name,
|
Name = p.Processor.Name,
|
||||||
CompanyName = p.Processor.Company.Name,
|
CompanyName = p.Processor.Company.Name,
|
||||||
ProcessorId = p.ProcessorId,
|
ProcessorId = p.ProcessorId,
|
||||||
MachineId = p.MachineId,
|
MachineId = p.MachineId,
|
||||||
Speed = p.Speed
|
Speed = p.Speed
|
||||||
})
|
})
|
||||||
.OrderBy(p => p.CompanyName)
|
.OrderBy(p => p.CompanyName)
|
||||||
.ThenBy(p => p.Name)
|
.ThenBy(p => p.Name)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -68,6 +66,7 @@ public class ProcessorsByMachineController(MarechaiContext context) : Controller
|
|||||||
public async Task DeleteAsync(long id)
|
public async Task DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
ProcessorsByMachine item = await context.ProcessorsByMachine.FindAsync(id);
|
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)
|
public async Task<long> CreateAsync(int processorId, int machineId, float? speed)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var item = new ProcessorsByMachine
|
var item = new ProcessorsByMachine
|
||||||
{
|
{
|
||||||
ProcessorId = processorId,
|
ProcessorId = processorId,
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,83 +44,79 @@ public class ProcessorsController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<ProcessorDto>> GetAsync() => await context.Processors
|
public Task<List<ProcessorDto>> GetAsync() => context.Processors.Select(p => new ProcessorDto
|
||||||
.Select(p => new ProcessorDto
|
{
|
||||||
{
|
Name = p.Name,
|
||||||
Name = p.Name,
|
CompanyName = p.Company.Name,
|
||||||
CompanyName = p.Company.Name,
|
CompanyId = p.Company.Id,
|
||||||
CompanyId = p.Company.Id,
|
ModelCode = p.ModelCode,
|
||||||
ModelCode = p.ModelCode,
|
Introduced = p.Introduced,
|
||||||
Introduced = p.Introduced,
|
Speed = p.Speed,
|
||||||
Speed = p.Speed,
|
Package = p.Package,
|
||||||
Package = p.Package,
|
Gprs = p.Gprs,
|
||||||
Gprs = p.Gprs,
|
GprSize = p.GprSize,
|
||||||
GprSize = p.GprSize,
|
Fprs = p.Fprs,
|
||||||
Fprs = p.Fprs,
|
FprSize = p.FprSize,
|
||||||
FprSize = p.FprSize,
|
Cores = p.Cores,
|
||||||
Cores = p.Cores,
|
ThreadsPerCore = p.ThreadsPerCore,
|
||||||
ThreadsPerCore = p.ThreadsPerCore,
|
Process = p.Process,
|
||||||
Process = p.Process,
|
ProcessNm = p.ProcessNm,
|
||||||
ProcessNm = p.ProcessNm,
|
DieSize = p.DieSize,
|
||||||
DieSize = p.DieSize,
|
Transistors = p.Transistors,
|
||||||
Transistors = p.Transistors,
|
DataBus = p.DataBus,
|
||||||
DataBus = p.DataBus,
|
AddrBus = p.AddrBus,
|
||||||
AddrBus = p.AddrBus,
|
SimdRegisters = p.SimdRegisters,
|
||||||
SimdRegisters = p.SimdRegisters,
|
SimdSize = p.SimdSize,
|
||||||
SimdSize = p.SimdSize,
|
L1Instruction = p.L1Instruction,
|
||||||
L1Instruction = p.L1Instruction,
|
L1Data = p.L1Data,
|
||||||
L1Data = p.L1Data,
|
L2 = p.L2,
|
||||||
L2 = p.L2,
|
L3 = p.L3,
|
||||||
L3 = p.L3,
|
InstructionSet = p.InstructionSet.Name,
|
||||||
InstructionSet = p.InstructionSet.Name,
|
Id = p.Id,
|
||||||
Id = p.Id,
|
InstructionSetExtensions = p.InstructionSetExtensions
|
||||||
InstructionSetExtensions =
|
.Select(e => e.Extension.Extension)
|
||||||
p.InstructionSetExtensions
|
.ToList()
|
||||||
.Select(e => e.Extension
|
})
|
||||||
.Extension)
|
.OrderBy(p => p.CompanyName)
|
||||||
.ToList()
|
.ThenBy(p => p.Name)
|
||||||
})
|
.ToListAsync();
|
||||||
.OrderBy(p => p.CompanyName)
|
|
||||||
.ThenBy(p => p.Name)
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.Where(p => p.MachineId == machineId)
|
||||||
.Select(p => new ProcessorDto
|
.Select(p => new ProcessorDto
|
||||||
{
|
{
|
||||||
Name = p.Processor.Name,
|
Name = p.Processor.Name,
|
||||||
CompanyName = p.Processor.Company.Name,
|
CompanyName = p.Processor.Company.Name,
|
||||||
CompanyId = p.Processor.Company.Id,
|
CompanyId = p.Processor.Company.Id,
|
||||||
ModelCode = p.Processor.ModelCode,
|
ModelCode = p.Processor.ModelCode,
|
||||||
Introduced = p.Processor.Introduced,
|
Introduced = p.Processor.Introduced,
|
||||||
Speed = p.Speed,
|
Speed = p.Speed,
|
||||||
Package = p.Processor.Package,
|
Package = p.Processor.Package,
|
||||||
Gprs = p.Processor.Gprs,
|
Gprs = p.Processor.Gprs,
|
||||||
GprSize = p.Processor.GprSize,
|
GprSize = p.Processor.GprSize,
|
||||||
Fprs = p.Processor.Fprs,
|
Fprs = p.Processor.Fprs,
|
||||||
FprSize = p.Processor.FprSize,
|
FprSize = p.Processor.FprSize,
|
||||||
Cores = p.Processor.Cores,
|
Cores = p.Processor.Cores,
|
||||||
ThreadsPerCore = p.Processor.ThreadsPerCore,
|
ThreadsPerCore = p.Processor.ThreadsPerCore,
|
||||||
Process = p.Processor.Process,
|
Process = p.Processor.Process,
|
||||||
ProcessNm = p.Processor.ProcessNm,
|
ProcessNm = p.Processor.ProcessNm,
|
||||||
DieSize = p.Processor.DieSize,
|
DieSize = p.Processor.DieSize,
|
||||||
Transistors = p.Processor.Transistors,
|
Transistors = p.Processor.Transistors,
|
||||||
DataBus = p.Processor.DataBus,
|
DataBus = p.Processor.DataBus,
|
||||||
AddrBus = p.Processor.AddrBus,
|
AddrBus = p.Processor.AddrBus,
|
||||||
SimdRegisters = p.Processor.SimdRegisters,
|
SimdRegisters = p.Processor.SimdRegisters,
|
||||||
SimdSize = p.Processor.SimdSize,
|
SimdSize = p.Processor.SimdSize,
|
||||||
L1Instruction = p.Processor.L1Instruction,
|
L1Instruction = p.Processor.L1Instruction,
|
||||||
L1Data = p.Processor.L1Data,
|
L1Data = p.Processor.L1Data,
|
||||||
L2 = p.Processor.L2,
|
L2 = p.Processor.L2,
|
||||||
L3 = p.Processor.L3,
|
L3 = p.Processor.L3,
|
||||||
InstructionSet = p.Processor.InstructionSet.Name,
|
InstructionSet = p.Processor.InstructionSet.Name,
|
||||||
Id = p.Processor.Id,
|
Id = p.Processor.Id,
|
||||||
InstructionSetExtensions =
|
InstructionSetExtensions = p.Processor.InstructionSetExtensions.Select(e => e.Extension.Extension).ToList()
|
||||||
p.Processor.InstructionSetExtensions.Select(e => e.Extension.Extension).ToList()
|
|
||||||
})
|
})
|
||||||
.OrderBy(p => p.CompanyName)
|
.OrderBy(p => p.CompanyName)
|
||||||
.ThenBy(p => p.Name)
|
.ThenBy(p => p.Name)
|
||||||
@@ -132,39 +126,38 @@ public class ProcessorsController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(p => new ProcessorDto
|
||||||
{
|
{
|
||||||
Name = p.Name,
|
Name = p.Name,
|
||||||
CompanyName = p.Company.Name,
|
CompanyName = p.Company.Name,
|
||||||
CompanyId = p.Company.Id,
|
CompanyId = p.Company.Id,
|
||||||
ModelCode = p.ModelCode,
|
ModelCode = p.ModelCode,
|
||||||
Introduced = p.Introduced,
|
Introduced = p.Introduced,
|
||||||
Speed = p.Speed,
|
Speed = p.Speed,
|
||||||
Package = p.Package,
|
Package = p.Package,
|
||||||
Gprs = p.Gprs,
|
Gprs = p.Gprs,
|
||||||
GprSize = p.GprSize,
|
GprSize = p.GprSize,
|
||||||
Fprs = p.Fprs,
|
Fprs = p.Fprs,
|
||||||
FprSize = p.FprSize,
|
FprSize = p.FprSize,
|
||||||
Cores = p.Cores,
|
Cores = p.Cores,
|
||||||
ThreadsPerCore = p.ThreadsPerCore,
|
ThreadsPerCore = p.ThreadsPerCore,
|
||||||
Process = p.Process,
|
Process = p.Process,
|
||||||
ProcessNm = p.ProcessNm,
|
ProcessNm = p.ProcessNm,
|
||||||
DieSize = p.DieSize,
|
DieSize = p.DieSize,
|
||||||
Transistors = p.Transistors,
|
Transistors = p.Transistors,
|
||||||
DataBus = p.DataBus,
|
DataBus = p.DataBus,
|
||||||
AddrBus = p.AddrBus,
|
AddrBus = p.AddrBus,
|
||||||
SimdRegisters = p.SimdRegisters,
|
SimdRegisters = p.SimdRegisters,
|
||||||
SimdSize = p.SimdSize,
|
SimdSize = p.SimdSize,
|
||||||
L1Instruction = p.L1Instruction,
|
L1Instruction = p.L1Instruction,
|
||||||
L1Data = p.L1Data,
|
L1Data = p.L1Data,
|
||||||
L2 = p.L2,
|
L2 = p.L2,
|
||||||
L3 = p.L3,
|
L3 = p.L3,
|
||||||
InstructionSet =
|
InstructionSet = p.InstructionSet.Name,
|
||||||
p.InstructionSet.Name,
|
InstructionSetId = p.InstructionSetId
|
||||||
InstructionSetId = p.InstructionSetId
|
})
|
||||||
})
|
.FirstOrDefaultAsync();
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -173,6 +166,7 @@ public class ProcessorsController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(ProcessorDto dto)
|
public async Task UpdateAsync(ProcessorDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Processor model = await context.Processors.FindAsync(dto.Id);
|
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)
|
public async Task<int> CreateAsync(ProcessorDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new Processor
|
var model = new Processor
|
||||||
{
|
{
|
||||||
AddrBus = dto.AddrBus,
|
AddrBus = dto.AddrBus,
|
||||||
@@ -257,6 +253,7 @@ public class ProcessorsController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Processor item = await context.Processors.FindAsync(id);
|
Processor item = await context.Processors.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,41 +44,40 @@ public class ResolutionsController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<ResolutionDto>> GetAsync() => await context.Resolutions
|
public Task<List<ResolutionDto>> GetAsync() => context.Resolutions.Select(r => new ResolutionDto
|
||||||
.Select(r => new ResolutionDto
|
{
|
||||||
{
|
Id = r.Id,
|
||||||
Id = r.Id,
|
Width = r.Width,
|
||||||
Width = r.Width,
|
Height = r.Height,
|
||||||
Height = r.Height,
|
Colors = r.Colors,
|
||||||
Colors = r.Colors,
|
Palette = r.Palette,
|
||||||
Palette = r.Palette,
|
Chars = r.Chars,
|
||||||
Chars = r.Chars,
|
Grayscale = r.Grayscale
|
||||||
Grayscale = r.Grayscale
|
})
|
||||||
})
|
.OrderBy(r => r.Width)
|
||||||
.OrderBy(r => r.Width)
|
.ThenBy(r => r.Height)
|
||||||
.ThenBy(r => r.Height)
|
.ThenBy(r => r.Chars)
|
||||||
.ThenBy(r => r.Chars)
|
.ThenBy(r => r.Grayscale)
|
||||||
.ThenBy(r => r.Grayscale)
|
.ThenBy(r => r.Colors)
|
||||||
.ThenBy(r => r.Colors)
|
.ThenBy(r => r.Palette)
|
||||||
.ThenBy(r => r.Palette)
|
.ToListAsync();
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(r => new ResolutionDto
|
||||||
{
|
{
|
||||||
Id = r.Id,
|
Id = r.Id,
|
||||||
Width = r.Width,
|
Width = r.Width,
|
||||||
Height = r.Height,
|
Height = r.Height,
|
||||||
Colors = r.Colors,
|
Colors = r.Colors,
|
||||||
Palette = r.Palette,
|
Palette = r.Palette,
|
||||||
Chars = r.Chars,
|
Chars = r.Chars,
|
||||||
Grayscale = r.Grayscale
|
Grayscale = r.Grayscale
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -89,6 +86,7 @@ public class ResolutionsController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(ResolutionDto dto)
|
public async Task UpdateAsync(ResolutionDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Resolution model = await context.Resolutions.FindAsync(dto.Id);
|
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)
|
public async Task<int> CreateAsync(ResolutionDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new Resolution
|
var model = new Resolution
|
||||||
{
|
{
|
||||||
Chars = dto.Chars,
|
Chars = dto.Chars,
|
||||||
@@ -135,6 +135,7 @@ public class ResolutionsController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Resolution item = await context.Resolutions.FindAsync(id);
|
Resolution item = await context.Resolutions.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,35 +44,35 @@ public class ScreensByMachineController(MarechaiContext context) : ControllerBas
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.Where(s => s.MachineId == machineId)
|
||||||
.Select(s => new ScreenByMachineDto
|
.Select(s => new ScreenByMachineDto
|
||||||
{
|
{
|
||||||
Id = s.Id,
|
Id = s.Id,
|
||||||
ScreenId = s.ScreenId,
|
ScreenId = s.ScreenId,
|
||||||
MachineId = s.MachineId,
|
MachineId = s.MachineId,
|
||||||
Screen = new ScreenDto
|
Screen = new ScreenDto
|
||||||
{
|
{
|
||||||
Diagonal = s.Screen.Diagonal,
|
Diagonal = s.Screen.Diagonal,
|
||||||
EffectiveColors = s.Screen.EffectiveColors,
|
EffectiveColors = s.Screen.EffectiveColors,
|
||||||
Height = s.Screen.Height,
|
Height = s.Screen.Height,
|
||||||
Id = s.Screen.Id,
|
Id = s.Screen.Id,
|
||||||
NativeResolution = new ResolutionDto
|
NativeResolution = new ResolutionDto
|
||||||
{
|
{
|
||||||
Chars = s.Screen.NativeResolution.Chars,
|
Chars = s.Screen.NativeResolution.Chars,
|
||||||
Colors = s.Screen.NativeResolution.Colors,
|
Colors = s.Screen.NativeResolution.Colors,
|
||||||
Grayscale = s.Screen.NativeResolution.Grayscale,
|
Grayscale = s.Screen.NativeResolution.Grayscale,
|
||||||
Height = s.Screen.NativeResolution.Height,
|
Height = s.Screen.NativeResolution.Height,
|
||||||
Id = s.Screen.NativeResolutionId,
|
Id = s.Screen.NativeResolutionId,
|
||||||
Palette = s.Screen.NativeResolution.Palette,
|
Palette = s.Screen.NativeResolution.Palette,
|
||||||
Width = s.Screen.NativeResolution.Width
|
Width = s.Screen.NativeResolution.Width
|
||||||
},
|
},
|
||||||
NativeResolutionId = s.Screen.NativeResolutionId,
|
NativeResolutionId = s.Screen.NativeResolutionId,
|
||||||
Type = s.Screen.Type,
|
Type = s.Screen.Type,
|
||||||
Width = s.Screen.Width
|
Width = s.Screen.Width
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -83,6 +81,7 @@ public class ScreensByMachineController(MarechaiContext context) : ControllerBas
|
|||||||
public async Task DeleteAsync(long id)
|
public async Task DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
ScreensByMachine item = await context.ScreensByMachine.FindAsync(id);
|
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)
|
public async Task<long> CreateAsync(int machineId, int screenId)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
if(context.ScreensByMachine.Any(s => s.MachineId == machineId && s.ScreenId == screenId)) return 0;
|
if(context.ScreensByMachine.Any(s => s.MachineId == machineId && s.ScreenId == screenId)) return 0;
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -47,69 +45,58 @@ public class ScreensController(MarechaiContext context) : ControllerBase
|
|||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<ScreenDto>> GetAsync() => (await context.Screens.Select(s => new ScreenDto
|
public async Task<List<ScreenDto>> GetAsync() => (await context.Screens.Select(s => new ScreenDto
|
||||||
{
|
{
|
||||||
Diagonal = s.Diagonal,
|
Diagonal = s.Diagonal,
|
||||||
EffectiveColors = s.EffectiveColors,
|
EffectiveColors = s.EffectiveColors,
|
||||||
Height = s.Height,
|
Height = s.Height,
|
||||||
Id = s.Id,
|
Id = s.Id,
|
||||||
Type = s.Type,
|
Type = s.Type,
|
||||||
Width = s.Width,
|
Width = s.Width,
|
||||||
NativeResolutionId =
|
NativeResolutionId = s.NativeResolutionId,
|
||||||
s.NativeResolutionId,
|
NativeResolution = new ResolutionDto
|
||||||
NativeResolution =
|
{
|
||||||
new ResolutionDto
|
Chars = s.NativeResolution.Chars,
|
||||||
{
|
Colors = s.NativeResolution.Colors,
|
||||||
Chars = s.NativeResolution
|
Grayscale = s.NativeResolution.Grayscale,
|
||||||
.Chars,
|
Height = s.NativeResolution.Height,
|
||||||
Colors = s.NativeResolution
|
Id = s.NativeResolution.Id,
|
||||||
.Colors,
|
Palette = s.NativeResolution.Palette,
|
||||||
Grayscale = s.NativeResolution
|
Width = s.NativeResolution.Width
|
||||||
.Grayscale,
|
}
|
||||||
Height = s.NativeResolution
|
})
|
||||||
.Height,
|
.ToListAsync()).OrderBy(s => s.Diagonal)
|
||||||
Id =
|
.ThenBy(s => s.EffectiveColors)
|
||||||
s.NativeResolution.Id,
|
.ThenBy(s => s.NativeResolution.ToString())
|
||||||
Palette = s.NativeResolution
|
.ThenBy(s => s.Type)
|
||||||
.Palette,
|
.ThenBy(s => s.Size)
|
||||||
Width = s.NativeResolution
|
.ToList();
|
||||||
.Width
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.ToListAsync()).OrderBy(s => s.Diagonal)
|
|
||||||
.ThenBy(s => s.EffectiveColors)
|
|
||||||
.ThenBy(s => s.NativeResolution.ToString())
|
|
||||||
.ThenBy(s => s.Type)
|
|
||||||
.ThenBy(s => s.Size)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(s => new ScreenDto
|
||||||
{
|
{
|
||||||
Diagonal = s.Diagonal,
|
Diagonal = s.Diagonal,
|
||||||
EffectiveColors = s.EffectiveColors,
|
EffectiveColors = s.EffectiveColors,
|
||||||
Height = s.Height,
|
Height = s.Height,
|
||||||
Id = s.Id,
|
Id = s.Id,
|
||||||
NativeResolution = new ResolutionDto
|
NativeResolution = new ResolutionDto
|
||||||
{
|
{
|
||||||
Chars = s.NativeResolution.Chars,
|
Chars = s.NativeResolution.Chars,
|
||||||
Colors = s.NativeResolution.Colors,
|
Colors = s.NativeResolution.Colors,
|
||||||
Grayscale = s.NativeResolution
|
Grayscale = s.NativeResolution.Grayscale,
|
||||||
.Grayscale,
|
Height = s.NativeResolution.Height,
|
||||||
Height = s.NativeResolution.Height,
|
Id = s.NativeResolution.Id,
|
||||||
Id = s.NativeResolution.Id,
|
Palette = s.NativeResolution.Palette,
|
||||||
Palette =
|
Width = s.NativeResolution.Width
|
||||||
s.NativeResolution.Palette,
|
},
|
||||||
Width = s.NativeResolution.Width
|
NativeResolutionId = s.NativeResolutionId,
|
||||||
},
|
Type = s.Type,
|
||||||
NativeResolutionId = s.NativeResolutionId,
|
Width = s.Width
|
||||||
Type = s.Type,
|
})
|
||||||
Width = s.Width
|
.FirstOrDefaultAsync();
|
||||||
})
|
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -118,6 +105,7 @@ public class ScreensController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(ScreenDto dto)
|
public async Task UpdateAsync(ScreenDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Screen model = await context.Screens.FindAsync(dto.Id);
|
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)
|
public async Task<int> CreateAsync(ScreenDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new Screen
|
var model = new Screen
|
||||||
{
|
{
|
||||||
Diagonal = dto.Diagonal,
|
Diagonal = dto.Diagonal,
|
||||||
@@ -168,6 +158,7 @@ public class ScreensController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
Screen item = await context.Screens.FindAsync(id);
|
Screen item = await context.Screens.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,32 +44,31 @@ public class SoftwareFamiliesController(MarechaiContext context) : ControllerBas
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(b => new SoftwareFamilyDto
|
||||||
{
|
{
|
||||||
Id = b.Id,
|
Id = b.Id,
|
||||||
Name = b.Name,
|
Name = b.Name,
|
||||||
Parent = b.Parent.Name,
|
Parent = b.Parent.Name,
|
||||||
Introduced = b.Introduced,
|
Introduced = b.Introduced,
|
||||||
ParentId = b.ParentId
|
ParentId = b.ParentId
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<SoftwareFamilyDto> GetAsync(ulong id) => await context.SoftwareFamilies
|
public Task<SoftwareFamilyDto> GetAsync(ulong id) => context.SoftwareFamilies.Where(b => b.Id == id)
|
||||||
.Where(b => b.Id == id)
|
.Select(b => new SoftwareFamilyDto
|
||||||
.Select(b => new SoftwareFamilyDto
|
{
|
||||||
{
|
Id = b.Id,
|
||||||
Id = b.Id,
|
Name = b.Name,
|
||||||
Name = b.Name,
|
Parent = b.Parent.Name,
|
||||||
Parent = b.Parent.Name,
|
Introduced = b.Introduced,
|
||||||
Introduced = b.Introduced,
|
ParentId = b.ParentId
|
||||||
ParentId = b.ParentId
|
})
|
||||||
})
|
.FirstOrDefaultAsync();
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -80,6 +77,7 @@ public class SoftwareFamiliesController(MarechaiContext context) : ControllerBas
|
|||||||
public async Task UpdateAsync(SoftwareFamilyDto dto)
|
public async Task UpdateAsync(SoftwareFamilyDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
SoftwareFamily model = await context.SoftwareFamilies.FindAsync(dto.Id);
|
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)
|
public async Task<ulong> CreateAsync(SoftwareFamilyDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return null;
|
if(userId is null) return null;
|
||||||
|
|
||||||
var model = new SoftwareFamily
|
var model = new SoftwareFamily
|
||||||
{
|
{
|
||||||
Name = dto.Name,
|
Name = dto.Name,
|
||||||
@@ -119,6 +119,7 @@ public class SoftwareFamiliesController(MarechaiContext context) : ControllerBas
|
|||||||
public async Task DeleteAsync(ulong id)
|
public async Task DeleteAsync(ulong id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
SoftwareFamily item = await context.SoftwareFamilies.FindAsync(id);
|
SoftwareFamily item = await context.SoftwareFamilies.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,64 +44,62 @@ public class SoftwareVariantsController(MarechaiContext context) : ControllerBas
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.OrderBy(b => b.SoftwareVersion.Family.Name)
|
||||||
.ThenBy(b => b.SoftwareVersion.Version)
|
.ThenBy(b => b.SoftwareVersion.Version)
|
||||||
.ThenBy(b => b.Name)
|
.ThenBy(b => b.Name)
|
||||||
.ThenBy(b => b.Version)
|
.ThenBy(b => b.Version)
|
||||||
.ThenBy(b => b.Introduced)
|
.ThenBy(b => b.Introduced)
|
||||||
.Select(b => new SoftwareVariantDto
|
.Select(b => new SoftwareVariantDto
|
||||||
{
|
{
|
||||||
Id = b.Id,
|
Id = b.Id,
|
||||||
Name = b.Name,
|
Name = b.Name,
|
||||||
Version = b.Version,
|
Version = b.Version,
|
||||||
Introduced = b.Introduced,
|
Introduced = b.Introduced,
|
||||||
ParentId = b.ParentId,
|
ParentId = b.ParentId,
|
||||||
Parent = b.Parent.Name ?? b.Parent.Version,
|
Parent = b.Parent.Name ?? b.Parent.Version,
|
||||||
SoftwareVersionId = b.SoftwareVersionId,
|
SoftwareVersionId = b.SoftwareVersionId,
|
||||||
SoftwareVersion =
|
SoftwareVersion =
|
||||||
b.SoftwareVersion.Name ??
|
b.SoftwareVersion.Name ??
|
||||||
b.SoftwareVersion.Version,
|
b.SoftwareVersion.Version,
|
||||||
MinimumMemory = b.MinimumMemory,
|
MinimumMemory = b.MinimumMemory,
|
||||||
RecommendedMemory = b.RecommendedMemory,
|
RecommendedMemory = b.RecommendedMemory,
|
||||||
RequiredStorage = b.RequiredStorage,
|
RequiredStorage = b.RequiredStorage,
|
||||||
PartNumber = b.PartNumber,
|
PartNumber = b.PartNumber,
|
||||||
SerialNumber = b.SerialNumber,
|
SerialNumber = b.SerialNumber,
|
||||||
ProductCode = b.ProductCode,
|
ProductCode = b.ProductCode,
|
||||||
CatalogueNumber = b.CatalogueNumber,
|
CatalogueNumber = b.CatalogueNumber,
|
||||||
DistributionMode = b.DistributionMode
|
DistributionMode = b.DistributionMode
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<SoftwareVariantDto> GetAsync(ulong id) => await context.SoftwareVariants
|
public Task<SoftwareVariantDto> GetAsync(ulong id) => context.SoftwareVariants.Where(b => b.Id == id)
|
||||||
.Where(b => b.Id == id)
|
.Select(b => new SoftwareVariantDto
|
||||||
.Select(b => new SoftwareVariantDto
|
{
|
||||||
{
|
Id = b.Id,
|
||||||
Id = b.Id,
|
Name = b.Name,
|
||||||
Name = b.Name,
|
Version = b.Version,
|
||||||
Version = b.Version,
|
Introduced = b.Introduced,
|
||||||
Introduced = b.Introduced,
|
ParentId = b.ParentId,
|
||||||
ParentId = b.ParentId,
|
Parent =
|
||||||
Parent =
|
b.Parent.Name ?? b.Parent.Version,
|
||||||
b.Parent.Name ?? b.Parent.Version,
|
SoftwareVersionId = b.SoftwareVersionId,
|
||||||
SoftwareVersionId = b.SoftwareVersionId,
|
SoftwareVersion = b.SoftwareVersion.Name ??
|
||||||
SoftwareVersion =
|
b.SoftwareVersion.Version,
|
||||||
b.SoftwareVersion.Name ??
|
MinimumMemory = b.MinimumMemory,
|
||||||
b.SoftwareVersion.Version,
|
RecommendedMemory = b.RecommendedMemory,
|
||||||
MinimumMemory = b.MinimumMemory,
|
RequiredStorage = b.RequiredStorage,
|
||||||
RecommendedMemory = b.RecommendedMemory,
|
PartNumber = b.PartNumber,
|
||||||
RequiredStorage = b.RequiredStorage,
|
SerialNumber = b.SerialNumber,
|
||||||
PartNumber = b.PartNumber,
|
ProductCode = b.ProductCode,
|
||||||
SerialNumber = b.SerialNumber,
|
CatalogueNumber = b.CatalogueNumber,
|
||||||
ProductCode = b.ProductCode,
|
DistributionMode = b.DistributionMode
|
||||||
CatalogueNumber = b.CatalogueNumber,
|
})
|
||||||
DistributionMode = b.DistributionMode
|
.FirstOrDefaultAsync();
|
||||||
})
|
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -112,6 +108,7 @@ public class SoftwareVariantsController(MarechaiContext context) : ControllerBas
|
|||||||
public async Task UpdateAsync(SoftwareVariantDto dto)
|
public async Task UpdateAsync(SoftwareVariantDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
SoftwareVariant model = await context.SoftwareVariants.FindAsync(dto.Id);
|
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)
|
public async Task<ulong> CreateAsync(SoftwareVariantDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return null;
|
if(userId is null) return null;
|
||||||
|
|
||||||
var model = new SoftwareVariant
|
var model = new SoftwareVariant
|
||||||
{
|
{
|
||||||
Name = dto.Name,
|
Name = dto.Name,
|
||||||
@@ -172,6 +171,7 @@ public class SoftwareVariantsController(MarechaiContext context) : ControllerBas
|
|||||||
public async Task DeleteAsync(ulong id)
|
public async Task DeleteAsync(ulong id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
SoftwareVariant item = await context.SoftwareVariants.FindAsync(id);
|
SoftwareVariant item = await context.SoftwareVariants.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,47 +44,45 @@ public class SoftwareVersionsController(MarechaiContext context) : ControllerBas
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<List<SoftwareVersionDto>> GetAsync() => await context.SoftwareVersions
|
public Task<List<SoftwareVersionDto>> GetAsync() => context.SoftwareVersions.OrderBy(b => b.Family.Name)
|
||||||
.OrderBy(b => b.Family.Name)
|
.ThenBy(b => b.Version)
|
||||||
.ThenBy(b => b.Version)
|
.ThenBy(b => b.Introduced)
|
||||||
.ThenBy(b => b.Introduced)
|
.Select(b => new SoftwareVersionDto
|
||||||
.Select(b => new SoftwareVersionDto
|
{
|
||||||
{
|
Id = b.Id,
|
||||||
Id = b.Id,
|
Family = b.Family.Name,
|
||||||
Family = b.Family.Name,
|
Name = b.Name,
|
||||||
Name = b.Name,
|
Codename = b.Codename,
|
||||||
Codename = b.Codename,
|
Version = b.Version,
|
||||||
Version = b.Version,
|
Introduced = b.Introduced,
|
||||||
Introduced = b.Introduced,
|
Previous = b.Previous.Name,
|
||||||
Previous = b.Previous.Name,
|
License = b.License.Name,
|
||||||
License = b.License.Name,
|
FamilyId = b.FamilyId,
|
||||||
FamilyId = b.FamilyId,
|
LicenseId = b.LicenseId,
|
||||||
LicenseId = b.LicenseId,
|
PreviousId = b.PreviousId
|
||||||
PreviousId = b.PreviousId
|
})
|
||||||
})
|
.ToListAsync();
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<SoftwareVersionDto> GetAsync(ulong id) => await context.SoftwareVersions
|
public Task<SoftwareVersionDto> GetAsync(ulong id) => context.SoftwareVersions.Where(b => b.Id == id)
|
||||||
.Where(b => b.Id == id)
|
.Select(b => new SoftwareVersionDto
|
||||||
.Select(b => new SoftwareVersionDto
|
{
|
||||||
{
|
Id = b.Id,
|
||||||
Id = b.Id,
|
Family = b.Family.Name,
|
||||||
Family = b.Family.Name,
|
Name = b.Name,
|
||||||
Name = b.Name,
|
Codename = b.Codename,
|
||||||
Codename = b.Codename,
|
Version = b.Version,
|
||||||
Version = b.Version,
|
Introduced = b.Introduced,
|
||||||
Introduced = b.Introduced,
|
Previous = b.Previous.Name,
|
||||||
Previous = b.Previous.Name,
|
License = b.License.Name,
|
||||||
License = b.License.Name,
|
FamilyId = b.FamilyId,
|
||||||
FamilyId = b.FamilyId,
|
LicenseId = b.LicenseId,
|
||||||
LicenseId = b.LicenseId,
|
PreviousId = b.PreviousId
|
||||||
PreviousId = b.PreviousId
|
})
|
||||||
})
|
.FirstOrDefaultAsync();
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -95,6 +91,7 @@ public class SoftwareVersionsController(MarechaiContext context) : ControllerBas
|
|||||||
public async Task UpdateAsync(SoftwareVersionDto dto)
|
public async Task UpdateAsync(SoftwareVersionDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
SoftwareVersion model = await context.SoftwareVersions.FindAsync(dto.Id);
|
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)
|
public async Task<ulong> CreateAsync(SoftwareVersionDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return null;
|
if(userId is null) return null;
|
||||||
|
|
||||||
var model = new SoftwareVersion
|
var model = new SoftwareVersion
|
||||||
{
|
{
|
||||||
Name = dto.Name,
|
Name = dto.Name,
|
||||||
@@ -142,6 +141,7 @@ public class SoftwareVersionsController(MarechaiContext context) : ControllerBas
|
|||||||
public async Task DeleteAsync(ulong id)
|
public async Task DeleteAsync(ulong id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
SoftwareVersion item = await context.SoftwareVersions.FindAsync(id);
|
SoftwareVersion item = await context.SoftwareVersions.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,19 +44,19 @@ public class SoundSynthsByMachineController(MarechaiContext context) : Controlle
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.Where(g => g.MachineId == machineId)
|
||||||
.Select(g => new SoundSynthByMachineDto
|
.Select(g => new SoundSynthByMachineDto
|
||||||
{
|
{
|
||||||
Id = g.Id,
|
Id = g.Id,
|
||||||
Name = g.SoundSynth.Name,
|
Name = g.SoundSynth.Name,
|
||||||
CompanyName = g.SoundSynth.Company.Name,
|
CompanyName = g.SoundSynth.Company.Name,
|
||||||
SoundSynthId = g.SoundSynthId,
|
SoundSynthId = g.SoundSynthId,
|
||||||
MachineId = g.MachineId
|
MachineId = g.MachineId
|
||||||
})
|
})
|
||||||
.OrderBy(g => g.CompanyName)
|
.OrderBy(g => g.CompanyName)
|
||||||
.ThenBy(g => g.Name)
|
.ThenBy(g => g.Name)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -67,6 +65,7 @@ public class SoundSynthsByMachineController(MarechaiContext context) : Controlle
|
|||||||
public async Task DeleteAsync(long id)
|
public async Task DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
SoundByMachine item = await context.SoundByMachine.FindAsync(id);
|
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)
|
public async Task<long> CreateAsync(int soundSynthId, int machineId)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var item = new SoundByMachine
|
var item = new SoundByMachine
|
||||||
{
|
{
|
||||||
SoundSynthId = soundSynthId,
|
SoundSynthId = soundSynthId,
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,31 +44,31 @@ public class SoundSynthsController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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.Name)
|
||||||
.ThenBy(s => s.ModelCode)
|
.ThenBy(s => s.ModelCode)
|
||||||
.Select(s => new SoundSynthDto
|
.Select(s => new SoundSynthDto
|
||||||
{
|
{
|
||||||
Id = s.Id,
|
Id = s.Id,
|
||||||
Name = s.Name,
|
Name = s.Name,
|
||||||
CompanyId = s.Company.Id,
|
CompanyId = s.Company.Id,
|
||||||
CompanyName = s.Company.Name,
|
CompanyName = s.Company.Name,
|
||||||
ModelCode = s.ModelCode,
|
ModelCode = s.ModelCode,
|
||||||
Introduced = s.Introduced,
|
Introduced = s.Introduced,
|
||||||
Voices = s.Voices,
|
Voices = s.Voices,
|
||||||
Frequency = s.Frequency,
|
Frequency = s.Frequency,
|
||||||
Depth = s.Depth,
|
Depth = s.Depth,
|
||||||
SquareWave = s.SquareWave,
|
SquareWave = s.SquareWave,
|
||||||
WhiteNoise = s.WhiteNoise,
|
WhiteNoise = s.WhiteNoise,
|
||||||
Type = s.Type
|
Type = s.Type
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.Where(s => s.MachineId == machineId)
|
||||||
.Select(s => s.SoundSynth)
|
.Select(s => s.SoundSynth)
|
||||||
.OrderBy(s => s.Company.Name)
|
.OrderBy(s => s.Company.Name)
|
||||||
@@ -97,23 +95,23 @@ public class SoundSynthsController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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
|
.Select(s => new SoundSynthDto
|
||||||
{
|
{
|
||||||
Id = s.Id,
|
Id = s.Id,
|
||||||
Name = s.Name,
|
Name = s.Name,
|
||||||
CompanyId = s.Company.Id,
|
CompanyId = s.Company.Id,
|
||||||
CompanyName = s.Company.Name,
|
CompanyName = s.Company.Name,
|
||||||
ModelCode = s.ModelCode,
|
ModelCode = s.ModelCode,
|
||||||
Introduced = s.Introduced,
|
Introduced = s.Introduced,
|
||||||
Voices = s.Voices,
|
Voices = s.Voices,
|
||||||
Frequency = s.Frequency,
|
Frequency = s.Frequency,
|
||||||
Depth = s.Depth,
|
Depth = s.Depth,
|
||||||
SquareWave = s.SquareWave,
|
SquareWave = s.SquareWave,
|
||||||
WhiteNoise = s.WhiteNoise,
|
WhiteNoise = s.WhiteNoise,
|
||||||
Type = s.Type
|
Type = s.Type
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -122,6 +120,7 @@ public class SoundSynthsController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task UpdateAsync(SoundSynthDto dto)
|
public async Task UpdateAsync(SoundSynthDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
SoundSynth model = await context.SoundSynths.FindAsync(dto.Id);
|
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)
|
public async Task<int> CreateAsync(SoundSynthDto dto)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var model = new SoundSynth
|
var model = new SoundSynth
|
||||||
{
|
{
|
||||||
Depth = dto.Depth,
|
Depth = dto.Depth,
|
||||||
@@ -176,6 +177,7 @@ public class SoundSynthsController(MarechaiContext context) : ControllerBase
|
|||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
SoundSynth item = await context.SoundSynths.FindAsync(id);
|
SoundSynth item = await context.SoundSynths.FindAsync(id);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// Copyright © 2003-2025 Natalia Portillo
|
// Copyright © 2003-2025 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@@ -34,7 +33,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
|
|
||||||
namespace Marechai.Server.Controllers;
|
namespace Marechai.Server.Controllers;
|
||||||
|
|
||||||
@@ -46,20 +44,20 @@ public class StorageByMachineController(MarechaiContext context) : ControllerBas
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[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)
|
.Where(s => s.MachineId == machineId)
|
||||||
.Select(s => new StorageByMachineDto
|
.Select(s => new StorageByMachineDto
|
||||||
{
|
{
|
||||||
Id = s.Id,
|
Id = s.Id,
|
||||||
Type = s.Type,
|
Type = s.Type,
|
||||||
Interface = s.Interface,
|
Interface = s.Interface,
|
||||||
Capacity = s.Capacity,
|
Capacity = s.Capacity,
|
||||||
MachineId = s.MachineId
|
MachineId = s.MachineId
|
||||||
})
|
})
|
||||||
.OrderBy(s => s.Type)
|
.OrderBy(s => s.Type)
|
||||||
.ThenBy(s => s.Interface)
|
.ThenBy(s => s.Interface)
|
||||||
.ThenBy(s => s.Capacity)
|
.ThenBy(s => s.Capacity)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
@@ -68,6 +66,7 @@ public class StorageByMachineController(MarechaiContext context) : ControllerBas
|
|||||||
public async Task DeleteAsync(long id)
|
public async Task DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return;
|
if(userId is null) return;
|
||||||
StorageByMachine item = await context.StorageByMachine.FindAsync(id);
|
StorageByMachine item = await context.StorageByMachine.FindAsync(id);
|
||||||
|
|
||||||
@@ -82,10 +81,12 @@ public class StorageByMachineController(MarechaiContext context) : ControllerBas
|
|||||||
[Authorize(Roles = "Admin,UberAdmin")]
|
[Authorize(Roles = "Admin,UberAdmin")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public async Task<long> CreateAsync(int machineId, StorageType type, StorageInterface @interface, long? capacity)
|
public async Task<long> CreateAsync(int machineId, StorageType type, StorageInterface @interface, long? capacity)
|
||||||
{
|
{
|
||||||
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
string userId = User.FindFirstValue(ClaimTypes.Sid);
|
||||||
|
|
||||||
if(userId is null) return 0;
|
if(userId is null) return 0;
|
||||||
|
|
||||||
var item = new StorageByMachine
|
var item = new StorageByMachine
|
||||||
{
|
{
|
||||||
MachineId = machineId,
|
MachineId = machineId,
|
||||||
|
|||||||
Reference in New Issue
Block a user