mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Refactor CompaniesController to use DTOs for machine and company operations
This commit is contained in:
@@ -190,9 +190,9 @@ public class CompaniesController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public Task<List<Machine>> GetMachinesAsync(int id) => context.Machines.Where(m => m.CompanyId == id)
|
public Task<List<MachineDto>> 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 MachineDto
|
||||||
{
|
{
|
||||||
Id = m.Id,
|
Id = m.Id,
|
||||||
Name = m.Name,
|
Name = m.Name,
|
||||||
@@ -215,7 +215,7 @@ public class CompaniesController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public Task<Company> GetSoldToAsync(int? id) => context.Companies.Select(c => new Company
|
public Task<CompanyDto> GetSoldToAsync(int? id) => context.Companies.Select(c => new CompanyDto
|
||||||
{
|
{
|
||||||
Id = c.Id,
|
Id = c.Id,
|
||||||
Name = c.Name
|
Name = c.Name
|
||||||
@@ -233,8 +233,8 @@ public class CompaniesController(MarechaiContext context) : ControllerBase
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public Task<List<CompanyDto>> GetCompaniesByCountryAsync(int countryId) => context.Companies.Include(c => c.Logos)
|
public Task<List<CompanyDto>> GetCompaniesByCountryAsync(int id) => context.Companies.Include(c => c.Logos)
|
||||||
.Where(c => c.CountryId == countryId)
|
.Where(c => c.CountryId == id)
|
||||||
.OrderBy(c => c.Name)
|
.OrderBy(c => c.Name)
|
||||||
.Select(c => new CompanyDto
|
.Select(c => new CompanyDto
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user