Se termina el CRUD para los catalogos: Clientes, Proveedores, tipo unidad, Ubicaciones

develop
Al Garcia 2 years ago
parent a14c5fd212
commit 616956b19b
  1. BIN
      .vs/AOLBackend/DesignTimeBuild/.dtbcache.v2
  2. BIN
      .vs/AOLBackend/FileContentIndex/3d7623a8-da92-4a1a-b860-08edca7a2da7.vsidx
  3. BIN
      .vs/AOLBackend/v17/.futdcache.v1
  4. BIN
      .vs/AOLBackend/v17/.suo
  5. BIN
      .vs/ProjectEvaluation/aolbackend.metadata.v2
  6. BIN
      .vs/ProjectEvaluation/aolbackend.projects.v2
  7. 12
      Contracts/Catalogos/ICatProveedoresRepository.cs
  8. 11
      Contracts/Catalogos/ICatTipoUnidadRepository.cs
  9. 11
      Contracts/Catalogos/ICatUbicacionesRepository.cs
  10. 2
      Controllers/Catalogos/CatClientesController.cs
  11. 41
      Controllers/Catalogos/CatProveedoresController.cs
  12. 40
      Controllers/Catalogos/CatTipoUnidadController.cs
  13. 41
      Controllers/Catalogos/CatUbicacionesController.cs
  14. 2
      Models/Catalogos/ICatProveedores.cs
  15. 9
      Models/Catalogos/ICatTipoUnidad.cs
  16. 4
      Models/Catalogos/ICatUbicaciones.cs
  17. 2
      Models/IUsuarios.cs
  18. 6
      Program.cs
  19. 3
      Repository/Catalogos/CatClientesRepository.cs
  20. 46
      Repository/Catalogos/CatProveedoresRepository.cs
  21. 46
      Repository/Catalogos/CatTipoUnidadRepository.cs
  22. 47
      Repository/Catalogos/CatUbicacionesRepository.cs
  23. BIN
      bin/Debug/net6.0/AOLBackend.dll
  24. BIN
      bin/Debug/net6.0/AOLBackend.pdb
  25. 2
      obj/Debug/net6.0/AOLBackend.csproj.CoreCompileInputs.cache
  26. BIN
      obj/Debug/net6.0/AOLBackend.dll
  27. BIN
      obj/Debug/net6.0/AOLBackend.pdb
  28. BIN
      obj/Debug/net6.0/ref/AOLBackend.dll
  29. BIN
      obj/Debug/net6.0/refint/AOLBackend.dll
  30. 23
      obj/staticwebassets.pack.sentinel

Binary file not shown.

Binary file not shown.

@ -0,0 +1,12 @@
using AOLBackend.Models.Catalogos;
namespace AOLBackend.Contracts.Catalogos
{
public interface ICatProveedoresRepository
{
public Task<ICatProveedores> Append(ICatProveedores data);
public Task<IEnumerable<ICatProveedores>> GetAll();
public Task<Boolean> Delete(int id);
}
}

@ -0,0 +1,11 @@
using AOLBackend.Models.Catalogos;
namespace AOLBackend.Contracts.Catalogos
{
public interface ICatTipoUnidadRepository
{
public Task<ICatTipoUnidad> Append(ICatTipoUnidad data);
public Task<IEnumerable<ICatTipoUnidad>> GetAll();
public Task<Boolean> Delete(int id);
}
}

@ -0,0 +1,11 @@
using AOLBackend.Models.Catalogos;
namespace AOLBackend.Contracts.Catalogos
{
public interface ICatUbicacionesRepository
{
public Task<ICatUbicaciones> Append(ICatUbicaciones data);
public Task<IEnumerable<ICatUbicaciones>> GetAll();
public Task<Boolean> Delete(int id);
}
}

@ -1,6 +1,4 @@
using AOLBackend.Contracts.Catalogos;
using AOLBackend.DTO;
using AOLBackend.DTO.Usuario;
using AOLBackend.Models.Catalogos;
using Microsoft.AspNetCore.Mvc;

@ -0,0 +1,41 @@
using AOLBackend.Contracts.Catalogos;
using AOLBackend.Models.Catalogos;
using Microsoft.AspNetCore.Mvc;
namespace AOLBackend.Controllers.Catalogos
{
[ApiController]
[Route("api/Catalogos/[controller]")]
public class CatProveedoresController : ControllerBase
{
private readonly ICatProveedoresRepository _Repo;
public CatProveedoresController(ICatProveedoresRepository Repo)
{
_Repo = Repo;
}
[HttpPost]
[Route("Append")]
public async Task<ICatProveedores> Append([FromBody] ICatProveedores data)
{
var entrada = await _Repo.Append(data);
return entrada;
}
[HttpGet]
[Route("Get")]
public async Task<IEnumerable<ICatProveedores>> GetAll()
{
var entrada = await _Repo.GetAll();
return entrada;
}
[HttpDelete("Delete/{id}")]
public async Task<IActionResult> Delete(int id)
{
await _Repo.Delete(id);
return new OkObjectResult(new { respuesta = "Se elimino el registro" });
}
}
}

@ -0,0 +1,40 @@
using AOLBackend.Contracts.Catalogos;
using AOLBackend.Models.Catalogos;
using Microsoft.AspNetCore.Mvc;
namespace AOLBackend.Controllers.Catalogos
{
[ApiController]
[Route("api/Catalogos/[controller]")]
public class CatTipoUnidadController : ControllerBase
{
private readonly ICatTipoUnidadRepository _Repo;
public CatTipoUnidadController(ICatTipoUnidadRepository Repo)
{
_Repo = Repo;
}
[HttpPost]
[Route("Append")]
public async Task<ICatTipoUnidad> Append([FromBody] ICatTipoUnidad data)
{
var entrada = await _Repo.Append(data);
return entrada;
}
[HttpGet]
[Route("Get")]
public async Task<IEnumerable<ICatTipoUnidad>> GetAll()
{
var entrada = await _Repo.GetAll();
return entrada;
}
[HttpDelete("Delete/{id}")]
public async Task<IActionResult> Delete(int id)
{
await _Repo.Delete(id);
return new OkObjectResult(new { respuesta = "Se elimino el registro" });
}
}
}

@ -0,0 +1,41 @@
using AOLBackend.Contracts.Catalogos;
using AOLBackend.Models.Catalogos;
using Microsoft.AspNetCore.Mvc;
namespace AOLBackend.Controllers.Catalogos
{
[ApiController]
[Route("api/Catalogos/[controller]")]
public class CatUbicacionesController : ControllerBase
{
private readonly ICatUbicacionesRepository _Repo;
public CatUbicacionesController(ICatUbicacionesRepository Repo)
{
_Repo = Repo;
}
[HttpPost]
[Route("Append")]
public async Task<ICatUbicaciones> Append([FromBody] ICatUbicaciones data)
{
var entrada = await _Repo.Append(data);
return entrada;
}
[HttpGet]
[Route("Get")]
public async Task<IEnumerable<ICatUbicaciones>> GetAll()
{
var entrada = await _Repo.GetAll();
return entrada;
}
[HttpDelete("Delete/{id}")]
public async Task<IActionResult> Delete(int id)
{
await _Repo.Delete(id);
return new OkObjectResult(new { respuesta = "Se elimino el registro" });
}
}
}

@ -2,7 +2,7 @@ namespace AOLBackend.Models.Catalogos
{
public class ICatProveedores
{
public int Id { get; set; }
public int id { get; set; }
public string Proveedor { get; set; } = null!;
public Byte Activo { get; set; } = 0!;
}

@ -0,0 +1,9 @@
namespace AOLBackend.Models.Catalogos
{
public class ICatTipoUnidad
{
public int id { get; set; } = 0!;
public string TipoUnidad { get; set; } = null!;
public Byte Activo { get; set; } = 0!;
}
}

@ -1,8 +1,8 @@
namespace AOLBackend.Models.Catalogos
{
public class IOrigenDestino
public class ICatUbicaciones
{
public int Id { get; set; }
public int id { get; set; }
public string Ubicacion { get; set; } = null!;
public Byte Activo { get; set; } = 0!;
}

@ -2,7 +2,7 @@
{
public class IUsuarios
{
public int Id { get; set; } = 0;
public int Id { get; set; } = 0!;
public string Usuario { get; set; } = null!;
public string Nombre { get; set; } = null!;
public string Contrasena { get; set; } = null!;

@ -10,7 +10,13 @@ using System.Text;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSingleton<DapperContext>();
builder.Services.AddScoped<IUsuarioRepository, UsuariosRepository>();
builder.Services.AddScoped<IMenuRepository, MenuRepository>();
// Catalogos
builder.Services.AddScoped<ICatClientesRepository, CatClientesRepository>();
builder.Services.AddScoped<ICatProveedoresRepository, CatProveedoresRepository>();
builder.Services.AddScoped<ICatUbicacionesRepository, CatUbicacionesRepository>();
builder.Services.AddScoped<ICatTipoUnidadRepository, CatTipoUnidadRepository>();
builder.Services.AddControllers();
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options =>

@ -1,9 +1,6 @@
using AOLBackend.Context;
using AOLBackend.Contracts.Catalogos;
using AOLBackend.DTO;
using AOLBackend.DTO.Usuario;
using AOLBackend.Models.Catalogos;
using AOLBackend.Services.Tools;
using Dapper;
using System.Data;

@ -0,0 +1,46 @@
using AOLBackend.Context;
using AOLBackend.Contracts.Catalogos;
using AOLBackend.Models.Catalogos;
using Dapper;
using System.Data;
namespace AOLBackend.Repository.Catalogos
{
public class CatProveedoresRepository : ICatProveedoresRepository
{
private readonly DapperContext _context;
private readonly IConfiguration _config;
public CatProveedoresRepository(DapperContext context, IConfiguration config)
{
_context = context;
_config = config;
}
public async Task<ICatProveedores> Append(ICatProveedores data)
{
var query = "[Catalogo.CatProveedores.Append]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<ICatProveedores>(query, new
{
@id = data.id,
@Proveedor = data.Proveedor,
}, commandType: CommandType.StoredProcedure);
return entrada.First();
}
public async Task<IEnumerable<ICatProveedores>> GetAll()
{
var query = "[Catalogo.CatProveedores.Get]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<ICatProveedores>(query, new { }, commandType: CommandType.StoredProcedure);
return entrada;
}
public async Task<Boolean> Delete(int id)
{
var query = "[Catalogo.CatProveedores.Delete]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<ICatProveedores>(query, new { @id }, commandType: CommandType.StoredProcedure);
return true;
}
}
}

@ -0,0 +1,46 @@
using AOLBackend.Context;
using AOLBackend.Contracts.Catalogos;
using AOLBackend.Models.Catalogos;
using Dapper;
using System.Data;
namespace AOLBackend.Repository.Catalogos
{
public class CatTipoUnidadRepository : ICatTipoUnidadRepository
{
private readonly DapperContext _context;
private readonly IConfiguration _config;
public CatTipoUnidadRepository(DapperContext context, IConfiguration config)
{
_context = context;
_config = config;
}
public async Task<ICatTipoUnidad> Append(ICatTipoUnidad data)
{
var query = "[Catalogo.CatTipoUnidad.Append]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<ICatTipoUnidad>(query, new
{
@id = data.id,
@TipoUnidad = data.TipoUnidad,
}, commandType: CommandType.StoredProcedure);
return entrada.First();
}
public async Task<IEnumerable<ICatTipoUnidad>> GetAll()
{
var query = "[Catalogo.CatTipoUnidad.Get]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<ICatTipoUnidad>(query, new { }, commandType: CommandType.StoredProcedure);
return entrada;
}
public async Task<Boolean> Delete(int id)
{
var query = "[Catalogo.CatTipoUnidad.Delete]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<ICatTipoUnidad>(query, new { @id }, commandType: CommandType.StoredProcedure);
return true;
}
}
}

@ -0,0 +1,47 @@
using AOLBackend.Context;
using AOLBackend.Contracts.Catalogos;
using AOLBackend.Models.Catalogos;
using Dapper;
using System.Data;
namespace AOLBackend.Repository.Catalogos
{
public class CatUbicacionesRepository : ICatUbicacionesRepository
{
private readonly DapperContext _context;
private readonly IConfiguration _config;
public CatUbicacionesRepository(DapperContext context, IConfiguration config)
{
_context = context;
_config = config;
}
public async Task<ICatUbicaciones> Append(ICatUbicaciones data)
{
var query = "[Catalogo.CatUbicaciones.Append]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<ICatUbicaciones>(query, new
{
@id = data.id,
@Ubicacion = data.Ubicacion,
}, commandType: CommandType.StoredProcedure);
return entrada.First();
}
public async Task<IEnumerable<ICatUbicaciones>> GetAll()
{
var query = "[Catalogo.CatUbicaciones.Get]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<ICatUbicaciones>(query, new { }, commandType: CommandType.StoredProcedure);
return entrada;
}
public async Task<Boolean> Delete(int id)
{
var query = "[Catalogo.CatUbicaciones.Delete]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<ICatUbicaciones>(query, new { @id }, commandType: CommandType.StoredProcedure);
return true;
}
}
}

Binary file not shown.

Binary file not shown.

@ -1 +1 @@
5c4d83d23e299243135bbd3e0f354dc85d91df62
4d7d0b7fb49ca16452b034f5986c30e9a38fc20a

Binary file not shown.

Binary file not shown.

@ -36,3 +36,26 @@
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0

Loading…
Cancel
Save