fix: ahora envia emails
This commit is contained in:
@@ -37,14 +37,13 @@ namespace Controladora
|
|||||||
bool resultado = repositorioFacturas.Guardar();
|
bool resultado = repositorioFacturas.Guardar();
|
||||||
t = ObtenerPorId(t);
|
t = ObtenerPorId(t);
|
||||||
string resultadolote = ControladoraLotes.Instance.DisminuirStock(t);
|
string resultadolote = ControladoraLotes.Instance.DisminuirStock(t);
|
||||||
|
|
||||||
// Convierte ReadOnlyCollection a List
|
var detallesList = t.Detalles;
|
||||||
var detallesList = new List<DetalleFactura>(t.MostrarDetalles());
|
|
||||||
|
|
||||||
if (resultado && resultadolote == "Se Descontaron los productos")
|
if (resultado && resultadolote == "Se Descontaron los productos")
|
||||||
{
|
{
|
||||||
if (ControladoraInformes.Instance.Informa) {
|
if (ControladoraInformes.Instance.Informa) {
|
||||||
// Envía el correo electrónico si la factura se cargó correctamente y el stock se decrementó
|
|
||||||
string emailResult = ControladoraInformes.Instance.EnviarEmail(
|
string emailResult = ControladoraInformes.Instance.EnviarEmail(
|
||||||
"Factura Cargada",
|
"Factura Cargada",
|
||||||
detallesList // Pasa la lista convertida
|
detallesList // Pasa la lista convertida
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Controladora
|
|||||||
{
|
{
|
||||||
string json = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
|
string json = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
|
||||||
File.WriteAllText(configpath, json);
|
File.WriteAllText(configpath, json);
|
||||||
InformeEmail.Instance.Informar = config.Informar;
|
|
||||||
}
|
}
|
||||||
catch (IOException) { throw; }
|
catch (IOException) { throw; }
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,8 @@ namespace Controladora
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return InformeEmail.Instance.Informar;
|
string jsonString = File.ReadAllText(configpath);
|
||||||
|
return JsonSerializer.Deserialize<ConfigEmail>(jsonString).Informar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public ConfigEmail RecuperarConfig()
|
public ConfigEmail RecuperarConfig()
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace Informes
|
|||||||
/// Envia Informes por Email
|
/// Envia Informes por Email
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public bool Informar { get; set; }
|
|
||||||
|
|
||||||
private static InformeEmail instance = new();
|
private static InformeEmail instance = new();
|
||||||
public static InformeEmail Instance
|
public static InformeEmail Instance
|
||||||
@@ -20,6 +20,11 @@ namespace Informes
|
|||||||
get { return instance; }
|
get { return instance; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private InformeEmail()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public string EnviarEmailFactura(string titulo, List<DetalleFactura> desc)
|
public string EnviarEmailFactura(string titulo, List<DetalleFactura> desc)
|
||||||
{
|
{
|
||||||
string? ret = null;
|
string? ret = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user