Exemple #1
0
 public void obtenerAfiliadoTest()
 {
     using (var entities = new SeguroEntities())
     {
         //prep
         AFILIADO afiliado = new AFILIADO();
         afiliado.RUT         = 12345;
         afiliado.VERIFICADOR = "K";
         entities.AFILIADO.Add(afiliado);
         entities.SaveChangesAsync();
         AccionesSeguro accionesSeguro = new AccionesSeguro();
         //Caso1: obtener afiliado correctamente
         AFILIADO result1 = accionesSeguro.obtenerAfiliado(afiliado.RUT.Value);
         Assert.AreNotEqual(result1, null);
         //Caso2: afiliado no existe
         try
         {
             AFILIADO result2 = accionesSeguro.obtenerAfiliado(0);
             Assert.Fail("No debería tocar esta línea");
         }
         catch (Exception)
         {
         }
     }
 }
Exemple #2
0
 public PLAN obtenerPlanAfiliado(AFILIADO afiliado)
 {
     using (var entities = new SeguroEntities())
     {
         PLAN plan = (from p in entities.PLAN
                      where afiliado.ID_PLAN == p.ID_PLAN
                      select p).First <PLAN>();
         return(plan);
     }
 }
Exemple #3
0
        public BENEFICIO obtenerBeneficioPrestacion(PRESTACION prestacion, List <BENEFICIO> beneficios)
        {
            BENEFICIO beneficio = null;

            using (var entities = new SeguroEntities())
            {
                beneficio = entities.BENEFICIO.Where(d => d.ID_PRESTACION == prestacion.ID_PRESTACION).FirstOrDefault();
            }
            return(beneficio);
        }
Exemple #4
0
 public static int crearTipoEmpresa(string nombre)
 {
     using (var entities = new SeguroEntities())
     {
         T_EMPRESA tipoEmpresa = new T_EMPRESA();
         tipoEmpresa.NOMBRE = nombre;
         entities.T_EMPRESA.Add(tipoEmpresa);
         entities.SaveChangesAsync();
         return(tipoEmpresa.ID_T_EMPRESA);
     }
 }
Exemple #5
0
 public static int crearAfiliado(int rut, string verificador)
 {
     using (var entities = new SeguroEntities())
     {
         AFILIADO afiliado = new AFILIADO();
         afiliado.RUT         = rut;
         afiliado.VERIFICADOR = verificador;
         entities.AFILIADO.Add(afiliado);
         entities.SaveChangesAsync();
         return(afiliado.ID_AFILIADO);
     }
 }
Exemple #6
0
 public static int crearPlan(string nombrePlan, int idEmpresa)
 {
     using (var entities = new SeguroEntities())
     {
         PLAN plan = new PLAN();
         plan.NOMBRE     = nombrePlan;
         plan.ID_EMPRESA = idEmpresa;
         entities.PLAN.Add(plan);
         entities.SaveChangesAsync();
         return(plan.ID_PLAN);
     }
 }
Exemple #7
0
 public static int crearEmpresa(string nombre, int idTipoEmpresa)
 {
     using (var entities = new SeguroEntities())
     {
         EMPRESA empresa = new EMPRESA();
         empresa.NOMBRE       = nombre;
         empresa.ID_T_EMPRESA = idTipoEmpresa;
         entities.EMPRESA.Add(empresa);
         entities.SaveChangesAsync();
         return(empresa.ID_EMPRESA);
     }
 }
Exemple #8
0
 public List <BENEFICIO> obtenerBeneficiosPlan(int idPlan)
 {
     using (var entities = new SeguroEntities())
     {
         List <BENEFICIO> beneficios = (
             from b in entities.BENEFICIO
             where idPlan == b.ID_PLAN
             select b
             ).ToList <BENEFICIO>();
         return(beneficios);
     }
 }
Exemple #9
0
 public static int crearBeneficio(decimal porcentaje, int limite, int idPlan, int idPrestacion)
 {
     using (var entities = new SeguroEntities())
     {
         BENEFICIO beneficio = new BENEFICIO();
         beneficio.ID_PLAN       = idPlan;
         beneficio.ID_PRESTACION = idPrestacion;
         beneficio.PORCENTAJE    = porcentaje;
         beneficio.LIMITE_DINERO = limite;
         entities.BENEFICIO.Add(beneficio);
         entities.SaveChangesAsync();
         return(beneficio.ID_BENEFICIO);
     }
 }
Exemple #10
0
 public static int crearPrestacion(string nombrePrestacion, string codigo)
 {
     using (var entities = new SeguroEntities())
     {
         PRESTACION prestacion = new PRESTACION();
         prestacion.NOMBRE = nombrePrestacion;
         prestacion.CODIGO = codigo;
         entities.PRESTACION.Add(prestacion);
         entities.SaveChangesAsync();
         return(prestacion.ID_PRESTACION);
         //return (from p in entities.PRESTACION
         //         select p).First<PRESTACION>().ID_PRESTACION;
     }
 }
Exemple #11
0
 public AFILIADO obtenerAfiliado(int rut)
 {
     using (var entities = new SeguroEntities())
     {
         List <AFILIADO> afiliados = (from a in entities.AFILIADO
                                      where a.RUT.Value == rut
                                      select a).ToList <AFILIADO>();
         if (afiliados.Count() == 0)
         {
             return(null);
         }
         else
         {
             return(afiliados.First <AFILIADO>());
         }
     }
 }
Exemple #12
0
 public void obtenerPrestacionTest()
 {
     using (var entities = new SeguroEntities())
     {
         #region Caso1
         //Prestación existe
         PRESTACION prestacion = new PRESTACION();
         prestacion.NOMBRE = "Prestacion ex";
         string codigo = "la prestacion" + System.DateTime.Now.ToString();
         prestacion.CODIGO = codigo;
         entities.PRESTACION.Add(prestacion);
         entities.SaveChangesAsync();
         int        idPrestacion = prestacion.ID_PRESTACION;
         PRESTACION result       = new AccionesSeguro().obtenerPrestacion(codigo);
         Assert.IsTrue(result.ID_PRESTACION == idPrestacion, "IDs no coinciden");
         #endregion
     }
 }
Exemple #13
0
 public void obtenerPlanAfiliadoTest()
 {
     using (var entities = new SeguroEntities())
     {
         #region prep
         T_EMPRESA tipoEmpresa = new T_EMPRESA();
         tipoEmpresa.NOMBRE = "Empresa publica";
         entities.T_EMPRESA.Add(tipoEmpresa);
         entities.SaveChangesAsync();
         EMPRESA empresa = new EMPRESA();
         empresa.NOMBRE       = "Fonasa";
         empresa.ID_T_EMPRESA = tipoEmpresa.ID_T_EMPRESA;
         entities.EMPRESA.Add(empresa);
         entities.SaveChangesAsync();
         PLAN plan = new PLAN();
         plan.NOMBRE     = "Plan bacan";
         plan.ID_EMPRESA = empresa.ID_EMPRESA;
         entities.PLAN.Add(plan);
         entities.SaveChangesAsync();
         AFILIADO afiliado = new AFILIADO();
         afiliado.RUT         = 999;
         afiliado.VERIFICADOR = "k";
         afiliado.ID_PLAN     = plan.ID_PLAN;
         AFILIADO sinPlan = new AFILIADO();
         sinPlan.RUT = 123;
         entities.AFILIADO.Add(sinPlan);
         entities.AFILIADO.Add(afiliado);
         entities.SaveChangesAsync();
         #endregion
         //Caso 1: obtiene plan correctamente
         AccionesSeguro accionesSeguro = new AccionesSeguro();
         PLAN           resultado1     = accionesSeguro.obtenerPlanAfiliado(afiliado);
         Assert.IsTrue(resultado1.NOMBRE == plan.NOMBRE);
         //Caso 2: afiliado no tiene plan
         try
         {
             PLAN resultado2 = accionesSeguro.obtenerPlanAfiliado(sinPlan);
             Assert.Fail("No debería tocar esta parte");
         }
         catch (Exception)
         {
         }
     }
 }
Exemple #14
0
        public string obtenerNombreEmpresa(int afiliadoRut)
        {
            AFILIADO afiliado = obtenerAfiliado(afiliadoRut);
            EMPRESA  empresa  = new EMPRESA();

            if (afiliado == null)
            {
                empresa.NOMBRE = "No tiene seguro";
            }
            else
            {
                using (var context = new SeguroEntities())
                {
                    afiliado.PLAN = context.PLAN.Find(afiliado.ID_PLAN);
                    empresa       = afiliado.PLAN.EMPRESA;
                }
            }
            return(empresa.NOMBRE);
        }
Exemple #15
0
 public PRESTACION obtenerPrestacion(string codigoPrestacion)
 {
     using (var entities = new SeguroEntities())
     {
         PRESTACION prestacion = new PRESTACION();
         try
         {
             prestacion = (
                 from p in entities.PRESTACION
                 where codigoPrestacion == p.CODIGO
                 select p
                 ).First <PRESTACION>();
             return(prestacion);
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Exemple #16
0
 public void obtenerBeneficiosPlanTest()
 {
     using (var entities = new SeguroEntities())
     {
         //Caso 1: obtener beneficio correctamente
         //preparacion
         //crear tipo empresa y empresa
         int idTipoEmpresa = TestUtil.crearTipoEmpresa("TipoEmpresaTest");
         int idEmpresa     = TestUtil.crearEmpresa("Empresa test", idTipoEmpresa);
         //crear plan, relacionar con empresa
         int idPlan = TestUtil.crearPlan("Plan test", idEmpresa);
         //crear prestación
         //los codigos deben ser únicos, por lo que se usa la hora actual como diferenciador
         string codigo       = "codigoTest" + System.DateTime.Now.ToString();
         int    idPrestacion = TestUtil.crearPrestacion("Test prestacion", codigo);
         //crear beneficio, relacionar con prestación y plan
         int idBeneficio = TestUtil.crearBeneficio(10, 100, idPlan, idPrestacion);
         //test
         AccionesSeguro   accionesSeguro      = new AccionesSeguro();
         List <BENEFICIO> resultadoBeneficios = accionesSeguro.obtenerBeneficiosPlan(idPlan);
         int idResultado = resultadoBeneficios.First <BENEFICIO>().ID_BENEFICIO;
         Assert.IsTrue(idResultado == idBeneficio, "Id beneficio no calza");
     }
 }