Skip to content

Commit

Permalink
v1
Browse files Browse the repository at this point in the history
  • Loading branch information
Igo Ventura committed Aug 7, 2021
1 parent 0d76a95 commit 4ed288f
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 5 deletions.
9 changes: 9 additions & 0 deletions DemoAPI.Infrastructure.Data/Context/FinancesDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,14 @@ public class FinancesDbContext : DbContext
public FinancesDbContext(DbContextOptions options) : base(options) {}

public DbSet<Transactions> Transactions { get; set; }

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Transactions>()
.Property(entity => entity.Price)
.HasPrecision(18, 2);

base.OnModelCreating(modelBuilder);
}
}
}
24 changes: 24 additions & 0 deletions DemoAPI/Controllers/TransactionsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using DemoAPI.Application.Interfaces;
using DemoAPI.Application.ViewModels;
using Microsoft.AspNetCore.Mvc;

namespace DemoAPI.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class TransactionsController : ControllerBase
{
private readonly ITransactionsService _transactionsService;

public TransactionsController(ITransactionsService transactionsService)
{
_transactionsService = transactionsService;
}

[HttpGet]
public TransactionsViewModel GetTransactions()
{
return _transactionsService.GetTransactions();
}
}
}
4 changes: 0 additions & 4 deletions DemoAPI/DemoAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@
<ProjectReference Include="..\DemoAPI.Infrastructure.IoC\DemoAPI.Infrastructure.IoC.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Controllers\" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions DemoAPI/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# DemoAPI

## Creating Docker Database

1. Run the docker command below

```bash
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=StrongPassword!!" -p 1433:1433 --name mssql -d mcr.microsoft.com/mssql/server:2019-latest
```

2. Run, in order, the scripts from **DemoAPI.Infrastructure.Data\DBScripts\**
2 changes: 1 addition & 1 deletion DemoAPI/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"AllowedHosts": "*",
"ConnectionStrings": {
// FIXME: Use a Parameter Store
"FinancesConnectionString": "Data Source=localhost;Initial Catalog=Finances;User id=sa;Password=StrongPassword!!;Integrated Security=True"
"FinancesConnectionString": "Data Source=localhost;Initial Catalog=Finances;User id=sa;Password=StrongPassword!!;"
}
}

0 comments on commit 4ed288f

Please sign in to comment.