Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

/ControleInvestimentos/ControleInvestimentos.API/bin/Debug/netcoreapp3.1
/ControleInvestimentos/ControleInvestimentos.API/obj/Debug/netcoreapp3.1
/ControleInvestimentos/ControleInvestimentos.API/obj
/ControleInvestimentos/ControleInvestimentos.Aplication/bin/Debug/netcoreapp3.1
/ControleInvestimentos/ControleInvestimentos.Aplication/obj
/ControleInvestimentos/ControleInvestimentos.Domain/bin/Debug/netcoreapp3.1
/ControleInvestimentos/ControleInvestimentos.Domain/obj/Debug/netcoreapp3.1
/ControleInvestimentos/ControleInvestimentos.Domain/obj
/ControleInvestimentos/ControleInvestimentos.Domain.Core/bin/Debug/netcoreapp3.1
/ControleInvestimentos/ControleInvestimentos.Domain.Core/obj
/ControleInvestimentos/ControleInvestimentos.Domain.Services/bin/Debug/netcoreapp3.1
/ControleInvestimentos/ControleInvestimentos.Domain.Services/obj
/ControleInvestimentos/ControleInvestimentos.Infrastructure/obj/Debug/netcoreapp3.1
/ControleInvestimentos/ControleInvestimentos.Infrastructure/obj
6 changes: 6 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
Binary file added .vs/kinvo/v16/.suo
Binary file not shown.
Binary file added .vs/slnx.sqlite
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.27">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.18" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ControleInvestimentos.Aplication\ControleInvestimentos.Aplication.csproj" />
<ProjectReference Include="..\ControleInvestimentos.Infrastructure\ControleInvestimentos.Infrastructure.csproj" />
</ItemGroup>


</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using ControleInvestimentos.Aplication.Interfaces;
using ControleInvestimentos.Domain.Entities;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ControleInvestimentos.API.Controllers
{
[Route("[controller]")]
[ApiController]
public class ClientesController : ControllerBase
{

private readonly IApplicationServiceCliente _applicationServiceCliente;


public ClientesController(IApplicationServiceCliente applicationServiceCliente)
{
this._applicationServiceCliente = applicationServiceCliente;
}

[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
return Ok(_applicationServiceCliente.GetAll());
}
[HttpGet("{id}")]
public ActionResult<string> Get(int id)
{
return Ok(_applicationServiceCliente.GetById(id));
}
[HttpPost]
public ActionResult Post([FromBody] Cliente cliente)
{
try
{
if (cliente == null)
return NotFound();
if (cliente.Id > 0)
cliente.Id = 0;

_applicationServiceCliente.Add(cliente);
return Ok("Cliente Cadastrado com sucesso!");
}
catch (Exception ex)
{

throw ex;
}


}

[HttpPut]
public ActionResult Put([FromBody] Cliente cliente)
{
try
{
if (cliente == null)
return NotFound();
_applicationServiceCliente.Update(cliente);
return Ok("Cliente Atualizado com sucesso!");
}
catch (Exception ex)
{

throw ex;
}
}
[HttpDelete()]
public ActionResult Delete([FromBody] Cliente cliente)
{
try
{
if (cliente == null)
return NotFound();

_applicationServiceCliente.Remove(cliente);
return Ok("Cliente Removido com sucesso!");
}
catch (Exception ex)
{

throw ex;
}

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using ControleInvestimentos.Aplication.Interfaces;
using ControleInvestimentos.Domain.Entities;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ControleInvestimentos.API.Controllers
{
[Route("[controller]")]
[ApiController]
public class TransacoesController : Controller
{
private readonly IApplicationServiceTransacao _applicationServiceTransacao;


public TransacoesController(IApplicationServiceTransacao applicationServiceTransacao)
{
this._applicationServiceTransacao = applicationServiceTransacao;
}

[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
return Ok(_applicationServiceTransacao.GetAll());
}
[HttpGet("{id}")]
public ActionResult<string> Get(int id)
{
return Ok(_applicationServiceTransacao.GetById(id));
}
[HttpPost]
public ActionResult Post([FromBody] Transacao transacao)
{
try
{
if (transacao == null)
return NotFound();
if (transacao.Id > 0)
transacao.Id = 0;

_applicationServiceTransacao.Add(transacao);
return Ok("Transação Cadastrada com sucesso!");
}
catch (Exception ex)
{

throw ex;
}
}

[HttpGet("/GetGroupByAcao")]
public ActionResult<IEnumerable<string>> GetGroupByAcao()
{
return Ok(_applicationServiceTransacao.GetGroupByAcao());
}

[HttpGet("/GetByCliente/{id}")]
public ActionResult<IEnumerable<string>> GetByCliente(int id)
{
return Ok(_applicationServiceTransacao.GetByCliente(id));
}


}
}
26 changes: 26 additions & 0 deletions ControleInvestimentos/ControleInvestimentos.API/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ControleInvestimentos.API
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:21973",
"sslPort": 44332
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"ControleInvestimentos.API": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
87 changes: 87 additions & 0 deletions ControleInvestimentos/ControleInvestimentos.API/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using ControleInvestimentos.Aplication;
using ControleInvestimentos.Aplication.Interfaces;
using ControleInvestimentos.Domain.Core.Interfaces.Repositorys;
using ControleInvestimentos.Domain.Core.Interfaces.Services;
using ControleInvestimentos.Domain.Services;
using ControleInvestimentos.Infrastructure.Data;
using ControleInvestimentos.Infrastructure.Data.Repositotrys;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ControleInvestimentos.API
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
#region [Context]
services.AddDbContext<PgSqlContext>(options =>
{
options.UseNpgsql(Configuration.GetConnectionString("Default"),
assembly => assembly.MigrationsAssembly(typeof(PgSqlContext).Assembly.FullName));
});
#endregion

services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Constrole Investimentos", Version = "v1", });
});
services.AddControllers();

services.AddScoped<IApplicationServiceCliente, ApplicationServiceCliente>();
services.AddScoped<IApplicationServiceTransacao, ApplicationServiceTransacao>();
services.AddScoped<IRepositoryCliente, RepositoryCliente>();
services.AddScoped<IRepositoryTransacao, RepositoryTransacao>();
services.AddScoped<IServiceCliente, ServiceCliente>();
services.AddScoped<IServiceTransacao, ServiceTransacao>();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseHttpsRedirection();

app.UseRouting();

app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});

app.UseSwagger();

app.UseSwaggerUI(c =>
{
c.RoutePrefix = string.Empty;
c.SwaggerEndpoint("/swagger/v1/swagger.json", "v1");
});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
13 changes: 13 additions & 0 deletions ControleInvestimentos/ControleInvestimentos.API/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Port=5432;Database=ControleInvestimentos;User Id=postgres;Password=satelite15;"
}
}
Loading