Skip to content

Commit 1976a13

Browse files
committed
Update ProductsController.cs
Iservicewrapper changed to IRepositoryWrapper, respective Dtos added
1 parent 9b1947d commit 1976a13

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Supermarket/V1/Controllers/ProductsController.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
using Microsoft.AspNetCore.Http;
44
using Microsoft.AspNetCore.Mvc;
55
using Supermarket.Core.Models;
6-
using Supermarket.Domain.Services.Contracts;
6+
using Supermarket.Core.Repositories.Contracts;
77
using Supermarket.Resources;
8+
using Supermarket.V1.Dtos.ProductDtos;
89
using System.Collections.Generic;
910
using System.Threading.Tasks;
1011

@@ -16,24 +17,24 @@ namespace Supermarket.V1.Controllers
1617
[ApiController]
1718
public class ProductsController : ControllerBase
1819
{
19-
private readonly IServiceWrapper _serviceWrapper;
20+
private readonly IRepositoryWrapper _repositoryWrapper;
2021
private readonly IMapper _mapper;
2122

22-
public ProductsController(IServiceWrapper serviceWrapper, IMapper mapper)
23+
public ProductsController(IRepositoryWrapper repositoryWrapper, IMapper mapper)
2324
{
24-
_serviceWrapper = serviceWrapper;
25+
_repositoryWrapper = repositoryWrapper;
2526
_mapper = mapper;
2627
}
2728

2829
[HttpGet]
2930
[ProducesResponseType(StatusCodes.Status200OK)]
3031
public async Task<IActionResult> GetAllAsync()
3132
{
32-
var products = await _serviceWrapper.Product.ListAsync();
33+
var products = await _repositoryWrapper.Product.ListAllProductsAsync();
3334

34-
var resources = _mapper.Map<IEnumerable<Product>, IEnumerable<ProductResource>>(products);
35+
var productDtos = _mapper.Map<IEnumerable<Product>, IEnumerable<ProductDto>>(products);
3536

36-
return Ok(resources);
37+
return Ok(productDtos);
3738
}
3839
}
3940
}

0 commit comments

Comments
 (0)