falta armar una ultima notificacion para el inquilino y setear el front para que mande las request bien
This commit is contained in:
@@ -2,6 +2,10 @@ using AlquilaFacil.Builder;
|
||||
using Entidades;
|
||||
using Entidades.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Minio;
|
||||
using Minio.DataModel;
|
||||
using Minio.DataModel.Args;
|
||||
using Minio.Exceptions;
|
||||
using Modelo;
|
||||
|
||||
namespace AlquilaFacil.Controllers;
|
||||
@@ -191,11 +195,27 @@ public class ContratoController: ControllerBase {
|
||||
Contrato? contr = RepositorioContratos.Singleton.ObtenerPreContratoPorId(idcontrato);
|
||||
if (contr == null) return BadRequest(new {message = "No hay un precontrato por esa id"});
|
||||
|
||||
return Ok(contr.Idgarantes);
|
||||
LinkedList<GaranteDto> list = new();
|
||||
foreach (var i in contr.Idgarantes) {
|
||||
list.AddFirst(new GaranteDtoBuilder()
|
||||
.SetCelular(i.Celular)
|
||||
.SetDni(i.Dni)
|
||||
.SetDomicilio(i.Domicilio)
|
||||
.SetDomicilioLaboral(i.Domiciliolaboral)
|
||||
.SetNombre(i.Nombre)
|
||||
.SetApellido(i.Apellido)
|
||||
.Build());
|
||||
}
|
||||
return Ok(list);
|
||||
}
|
||||
|
||||
private readonly IMinioClient mc;
|
||||
public ContratoController(IMinioClient mcc){
|
||||
mc = mcc;
|
||||
}
|
||||
|
||||
[HttpPost("api/contratos/subirContrato")]
|
||||
public IActionResult subirContrato([FromHeader(Name = "Auth")]string Auth, [FromForm]long idcontrato =0, IFormFile contrato) {
|
||||
public IActionResult subirContrato([FromHeader(Name = "Auth")]string Auth, [FromForm]long idcontrato, IFormFile contrato) {
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
@@ -209,14 +229,11 @@ public class ContratoController: ControllerBase {
|
||||
if (!Path.GetExtension(contrato.FileName).Equals(".pdf", StringComparison.OrdinalIgnoreCase)) return BadRequest(new { message = "El archivo debe tener la extensión .pdf." });
|
||||
|
||||
string nuevoNombreArchivo = $"id:{contr.Id}-inq:{contr.Dniinquilino}-propi:{contr.Dnipropietario}-idprop:{contr.Idpropiedad}.pdf";
|
||||
|
||||
var s3Client = new AmazonS3Client("aVO9C3PqeK1hiPCyqZCj", "szj58kceWG3GcRZ8P1QCQiv5tSjMI7iD5zfjneTT", new AmazonS3Config
|
||||
{
|
||||
ServiceURL = "http://192.168.1.11",
|
||||
ForcePathStyle = true
|
||||
});
|
||||
|
||||
var ret = subirContrato(contrato, mc, nuevoNombreArchivo).Wait();
|
||||
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost("api/contratos/aceptarContrato")]
|
||||
@@ -228,6 +245,32 @@ public class ContratoController: ControllerBase {
|
||||
return Ok();
|
||||
}
|
||||
|
||||
private async Task<bool> subirContrato(IFormFile f, IMinioClient m, string flname) {
|
||||
try {
|
||||
var buck = new BucketExistsArgs().WithBucket("alquilafacil");
|
||||
bool encontrado = await m.BucketExistsAsync(buck).ConfigureAwait(false);
|
||||
|
||||
if(!encontrado){
|
||||
var mb = new MakeBucketArgs().WithBucket("alquilafacil");
|
||||
await m.MakeBucketAsync(mb).ConfigureAwait(false);
|
||||
}
|
||||
using (var stream = f.OpenReadStream()){
|
||||
|
||||
var putbj = new PutObjectArgs()
|
||||
.WithBucket("alquilafacil")
|
||||
.WithObject(flname)
|
||||
.WithStreamData(stream)
|
||||
.WithContentType("application/pdf")
|
||||
.WithObjectSize(f.Length);
|
||||
await m.PutObjectAsync(putbj).ConfigureAwait(false);
|
||||
}
|
||||
return true;
|
||||
} catch (MinioException e ) {
|
||||
Console.Error.WriteLine(e.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private string ValidarCancelarDto(CancelarPrecontratoDto dto) {
|
||||
if (dto == null) return "dto nulo";
|
||||
string ret = "";
|
||||
|
||||
Reference in New Issue
Block a user