62 lines
1.4 KiB
C#
62 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using DALL;
|
|
using MLL;
|
|
|
|
namespace BLL
|
|
{
|
|
public class BLLEmpresa
|
|
{
|
|
private readonly DALEmpresa dal;
|
|
|
|
public BLLEmpresa(string connectionString)
|
|
{
|
|
dal = new DALEmpresa(connectionString);
|
|
}//Constructor
|
|
|
|
// 🔹 LISTAR
|
|
public List<ModeloEmpresa> Listar()
|
|
{
|
|
return dal.Listar();
|
|
}
|
|
|
|
// 🔹 CARREGAR POR ID
|
|
public ModeloEmpresa CarregarModeloEmpresa(int id)
|
|
{
|
|
return dal.CarregarModeloEmpresa(id);
|
|
}
|
|
|
|
// 🔹 INSERIR
|
|
public bool Inserir(ModeloEmpresa obj)
|
|
{
|
|
// validação básica (pode evoluir depois)
|
|
if (string.IsNullOrWhiteSpace(obj.Nome) ||
|
|
string.IsNullOrWhiteSpace(obj.CNPJ) ||
|
|
string.IsNullOrWhiteSpace(obj.Email))
|
|
return false;
|
|
|
|
return dal.Inserir(obj);
|
|
}
|
|
|
|
// 🔹 ALTERAR
|
|
public bool Alterar(ModeloEmpresa obj)
|
|
{
|
|
if (obj.Id <= 0)
|
|
return false;
|
|
|
|
return dal.Alterar(obj);
|
|
}
|
|
|
|
// 🔹 EXCLUIR
|
|
public bool Excluir(int id)
|
|
{
|
|
if (id <= 0)
|
|
return false;
|
|
|
|
return dal.Excluir(id);
|
|
}
|
|
public ModeloEmpresa? CarregarEmpresaAtiva()
|
|
{
|
|
return dal.CarregarEmpresaAtiva();
|
|
}
|
|
}
|
|
} |