-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProductsController.cs
More file actions
33 lines (29 loc) · 1.24 KB
/
Copy pathProductsController.cs
File metadata and controls
33 lines (29 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using ETicaretAPI.Application.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace ETicaretAPI.API.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ProductsController : ControllerBase
{
readonly private IProductWriteRepository _productWriteRepository;
readonly private IProductReadRepository _productReadRepository;
public ProductsController(IProductWriteRepository productWriteRepository, IProductReadRepository productReadRepository)
{
_productWriteRepository = productWriteRepository;
_productReadRepository = productReadRepository;
}
[HttpGet]
public async void Get()
{
await _productWriteRepository.AddRangeAsync(new()
{
new() { Id = Guid.NewGuid(), Name = "Product 1", Price = 100, CreateDate = DateTime.UtcNow, Stock = 10 },
new() { Id = Guid.NewGuid(), Name = "Product 2", Price = 200, CreateDate = DateTime.UtcNow, Stock = 20 },
new() { Id = Guid.NewGuid(), Name = "Product 3", Price = 300, CreateDate = DateTime.UtcNow, Stock = 120 }
});
await _productWriteRepository.SaveAsync();
}
}
}