-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14649a8
commit 53bf889
Showing
54 changed files
with
1,144 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Cors; | ||
using Microsoft.AspNetCore.Mvc; | ||
using OpenAdm.Application.Interfaces; | ||
using OpenAdm.Domain.Model.Carrinho; | ||
|
||
namespace OpenAdm.Api.Controllers; | ||
|
||
[ApiController] | ||
[Route("carrinho")] | ||
[Authorize(AuthenticationSchemes = "Bearer")] | ||
public class CarrinhoController : ControllerBaseApi | ||
{ | ||
private readonly ICarrinhoService _carrinhoService; | ||
|
||
public CarrinhoController(ICarrinhoService carrinhoService) | ||
{ | ||
_carrinhoService = carrinhoService; | ||
} | ||
|
||
[EnableCors("iscasluneoriginwithpost")] | ||
[HttpPut("adicionar")] | ||
public async Task<IActionResult> AdicionarCarinho(AddCarrinhoModel addCarrinhoDto) | ||
{ | ||
try | ||
{ | ||
await _carrinhoService.AdicionarProdutoAsync(addCarrinhoDto); | ||
return Ok(new { message = "Produto adicionado com sucesso!" }); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return await HandleErrorAsync(ex); | ||
} | ||
} | ||
|
||
[HttpGet("get-carrinho")] | ||
public async Task<IActionResult> GetCarrinho() | ||
{ | ||
try | ||
{ | ||
var result = await _carrinhoService.GetCarrinhoAsync(); | ||
return Ok(result); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return await HandleErrorAsync(ex); | ||
} | ||
} | ||
|
||
[HttpGet("get-carrinho-count")] | ||
public async Task<IActionResult> GetCarrinhoCount() | ||
{ | ||
try | ||
{ | ||
var result = await _carrinhoService.GetCountCarrinhoAsync(); | ||
return Ok(result); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return await HandleErrorAsync(ex); | ||
} | ||
} | ||
|
||
[HttpDelete("delete-produto-carrinho")] | ||
public async Task<IActionResult> DeleteProdutCarrinho([FromQuery] Guid produtoId) | ||
{ | ||
try | ||
{ | ||
var result = await _carrinhoService.DeleteProdutoCarrinhoAsync(produtoId); | ||
return Ok(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return await HandleErrorAsync(ex); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using OpenAdm.Application.Models.Carrinhos; | ||
using OpenAdm.Domain.Model.Carrinho; | ||
|
||
namespace OpenAdm.Application.Interfaces; | ||
|
||
public interface ICarrinhoService | ||
{ | ||
Task<bool> AdicionarProdutoAsync(AddCarrinhoModel addCarrinhoModel); | ||
Task<IList<CarrinhoViewModel>> GetCarrinhoAsync(); | ||
Task<int> GetCountCarrinhoAsync(); | ||
Task<bool> DeleteProdutoCarrinhoAsync(Guid produtoId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using OpenAdm.Application.Models.Logins; | ||
using OpenAdm.Application.Models.Tokens; | ||
|
||
namespace OpenAdm.Application.Interfaces; | ||
|
||
public interface ILoginUsuarioService | ||
{ | ||
Task<ResponseLoginUsuarioViewModel> LoginAsync(RequestLogin requestLogin, ConfiguracaoDeToken configuracaoDeToken); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
using OpenAdm.Application.Models.Tokens; | ||
using OpenAdm.Application.Models.Usuarios; | ||
|
||
namespace OpenAdm.Application.Interfaces; | ||
|
||
public interface ITokenService | ||
{ | ||
string GenerateToken(object obj, ConfiguracaoDeToken configGenerateToken); | ||
bool IsFuncionario(); | ||
UsuarioViewModel GetTokenUsuarioViewModel(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using OpenAdm.Application.Models.Categorias; | ||
|
||
namespace OpenAdm.Application.Models.Carrinhos; | ||
|
||
public class CarrinhoViewModel | ||
{ | ||
public Guid Id { get; set; } | ||
public long Numero { get; set; } | ||
public string Descricao { get; set; } = string.Empty; | ||
public string? EspecificacaoTecnica { get; set; } | ||
public string Foto { get; set; } = string.Empty; | ||
public List<TamanhoCarrinhoViewModel>? Tamanhos { get; set; } = new(); | ||
public List<PesoCarrinhoViewModel>? Pesos { get; set; } = new(); | ||
public Guid CategoriaId { get; set; } | ||
public CategoriaViewModel? Categoria { get; set; } = null!; | ||
public string? Referencia { get; set; } | ||
} |
7 changes: 7 additions & 0 deletions
7
OpenAdm.Application/Models/Carrinhos/PesoCarrinhoViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace OpenAdm.Application.Models.Carrinhos; | ||
|
||
public class PesoCarrinhoViewModel : BaseModel | ||
{ | ||
public string Descricao { get; set; } = string.Empty; | ||
public QuantidadeProdutoCarrinhoViewModel PrecoProduto { get; set; } = new(); | ||
} |
7 changes: 7 additions & 0 deletions
7
OpenAdm.Application/Models/Carrinhos/QuantidadeProdutoCarrinhoViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace OpenAdm.Application.Models.Carrinhos; | ||
|
||
public class QuantidadeProdutoCarrinhoViewModel | ||
{ | ||
public Guid Id { get; set; } | ||
public decimal Quantidade { get; set; } | ||
} |
7 changes: 7 additions & 0 deletions
7
OpenAdm.Application/Models/Carrinhos/TamanhoCarrinhoViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace OpenAdm.Application.Models.Carrinhos; | ||
|
||
public class TamanhoCarrinhoViewModel : BaseModel | ||
{ | ||
public string Descricao { get; set; } = string.Empty; | ||
public QuantidadeProdutoCarrinhoViewModel PrecoProduto { get; set; } = new(); | ||
} |
9 changes: 9 additions & 0 deletions
9
OpenAdm.Application/Models/Logins/ResponseLoginUsuarioViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using OpenAdm.Application.Models.Usuarios; | ||
|
||
namespace OpenAdm.Application.Models.Logins; | ||
|
||
public class ResponseLoginUsuarioViewModel(UsuarioViewModel usuario, string token) | ||
{ | ||
public UsuarioViewModel Usuario { get; set; } = usuario; | ||
public string Token { get; set; } = token; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using OpenAdm.Domain.Entities; | ||
|
||
namespace OpenAdm.Application.Models.Usuarios; | ||
|
||
public class UsuarioViewModel : BaseModel | ||
{ | ||
public string Nome { get; set; } = string.Empty; | ||
public string Email { get; set; } = string.Empty; | ||
public string? Telefone { get; set; } | ||
public string? Cnpj { get; set; } | ||
|
||
public UsuarioViewModel ToModel(Usuario entity) | ||
{ | ||
Id = entity.Id; | ||
DataDeCriacao = entity.DataDeCriacao; | ||
DataDeAtualizacao = entity.DataDeAtualizacao; | ||
Email = entity.Email; | ||
Numero = entity.Numero; | ||
Telefone = entity.Telefone; | ||
Nome = entity.Nome; | ||
Cnpj = entity.Cnpj; | ||
|
||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.