Skip to content

Commit

Permalink
[SOA-025][Enhancement] Add [FromRoute] and NameMethod to the GET requ…
Browse files Browse the repository at this point in the history
…ests (#43)
  • Loading branch information
LyQuocCuong authored Jul 20, 2023
1 parent 1208bc9 commit e590f0f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ public CompanyController(ControllerParams controllerParams) : base(controllerPar
}

[HttpGet]
[Route("companies")]
public IActionResult GetAll()
[Route("companies", Name = "GetAllCompanies")]
public IActionResult GetAllCompanies()
{
IEnumerable<CompanyDto> companyDtos = _services.Company.GetAll();
return Ok(companyDtos);
}

[HttpGet]
[Route("companies/{id:guid}")]
public IActionResult GetById(Guid id)
[Route("companies/{id:guid}", Name = "GetCompanyById")]
public IActionResult GetCompanyById([FromRoute]Guid id)
{
CompanyDto? companyDto = _services.Company.GetById(id);
if (companyDto == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ public CustomerController(ControllerParams controllerParams) : base(controllerPa
}

[HttpGet]
[Route("customers")]
public IActionResult GetAll()
[Route("customers", Name = "GetAllCustomers")]
public IActionResult GetAllCustomers()
{
IEnumerable<CustomerDto> employeeDto = _services.Customer.GetAll();
return Ok(employeeDto);
}

[HttpGet]
[Route("customers/{id:guid}", Name = "GetCustomerById")]
public IActionResult GetCustomerById(Guid id)
public IActionResult GetCustomerById([FromRoute]Guid id)
{
CustomerDto? employeeDto = _services.Customer.GetById(id);
if (employeeDto == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ public EmployeeController(ControllerParams controllerParams) : base(controllerPa
}

[HttpGet]
[Route("employees")]
public IActionResult GetAll()
[Route("employees", Name = "GetAllEmployees")]
public IActionResult GetAllEmployees()
{
IEnumerable<EmployeeDto> employeeDtos = _services.Employee.GetAll();
return Ok(employeeDtos);
}

[HttpGet]
[Route("employees/{id:guid}", Name = "GetEmployeeById")]
public IActionResult GetEmployeeById(Guid id)
public IActionResult GetEmployeeById([FromRoute]Guid id)
{
EmployeeDto? employeeDto = _services.Employee.GetById(id);
if (employeeDto == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ public ProductController(ControllerParams controllerParams) : base(controllerPar
}

[HttpGet]
[Route("products")]
public IActionResult GetAll()
[Route("products", Name = "GetAllProducts")]
public IActionResult GetAllProducts()
{
IEnumerable<ProductDto> productDtos = _services.Product.GetAll();
return Ok(productDtos);
}

[HttpGet]
[Route("products/{id:guid}", Name = "GetProductById")]
public IActionResult GetProductById(Guid id)
public IActionResult GetProductById([FromRoute]Guid id)
{
ProductDto? productDto = _services.Product.GetById(id);
if (productDto == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ public StoreController(ControllerParams controllerParams) : base(controllerParam
}

[HttpGet]
[Route("stores")]
public IActionResult GetAll()
[Route("stores", Name = "GetAllStores")]
public IActionResult GetAllStores()
{
IEnumerable<StoreDto> storeDtos = _services.Store.GetAll();
return Ok(storeDtos);
}

[HttpGet]
[Route("stores/{id:guid}", Name = "GetStoreById")]
public IActionResult GetById(Guid id)
public IActionResult GetStoreById([FromRoute]Guid id)
{
StoreDto? storeDto = _services.Store.GetById(id);
if (storeDto == null)
Expand Down

0 comments on commit e590f0f

Please sign in to comment.