Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre,DuracionHoras,Monto")] Prestacion prestacion)
        {
            if (id != prestacion.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(prestacion);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PrestacionExists(prestacion.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(prestacion));
        }
        public Prestacion GetAllProducts()
        {
            try
            {
                int NroPrestacion = 696;

                Prestacion        p  = new Prestacion();
                PrestacionService ps = new PrestacionService(p);

                ps.InicializarModelo(NroPrestacion);


                //e.EtapaID = "4.1_7.1";
                //e.Descripcion = "Aprobacion de Proyectos";
                //p.ProgramaID = 5;
                //p.Descripcion = "Programa Jovenes";
                //p.Etapa = new List<Etapas>();
                //p.Etapa.Add(e);


                return(p);
            }
            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e);
                return(p);
            }
        }
Ejemplo n.º 3
0
        public GenericApiResponse <Prestacion> ModificarPrestacion(int id, [FromBody] Prestacion prestacion)
        {
            GenericApiResponse <Prestacion> response = new GenericApiResponse <Prestacion>();

            if (id != prestacion.Id)
            {
                response.OK          = false;
                response.Error.title = "Id no coincide";
                response.Error.error = "El id no coincide con el id del cuerpo";
                return(response);
            }
            var temp = contexto.Prestacion.FirstOrDefault(p => p.Id == id);

            if (temp == null)
            {
                response.OK          = false;
                response.Error.title = "No se encontro el registro";
                response.Error.error = "No se encontro la prestacion con id= {id} para ser modificada";
                return(response);
            }

            temp.Nombre             = prestacion.Nombre;
            temp.PorcentajeDeSueldo = prestacion.PorcentajeDeSueldo;

            contexto.Entry(temp).State = EntityState.Modified;
            contexto.SaveChanges();
            response.OK   = true;
            response.Data = temp;
            return(response);
        }
Ejemplo n.º 4
0
 public static void Actualizar(this Prestacion empresadb, Prestacion prestacion)
 {
     empresadb.Zona        = prestacion.Zona;
     empresadb.Profesional = prestacion.Profesional;
     empresadb.Paciente    = prestacion.Paciente;
     empresadb.Inicio      = prestacion.Inicio;
     empresadb.Fin         = prestacion.Fin;
     empresadb.Cantidad    = prestacion.Cantidad;
 }
Ejemplo n.º 5
0
        private Prestacion map_prestacion_fila()
        {
            Prestacion oPrestacion = new Prestacion();

            oPrestacion.id_prestacion  = int.Parse(dgvPrestacion.CurrentRow.Cells["col_id_prestacion"].Value.ToString());
            oPrestacion.cod_prestacion = dgvPrestacion.CurrentRow.Cells["col_cod_prestacion"].Value.ToString();
            oPrestacion.nombre         = dgvPrestacion.CurrentRow.Cells["col_nombre"].Value.ToString();
            oPrestacion.descripcion    = dgvPrestacion.CurrentRow.Cells["col_descripcion"].Value.ToString();
            return(oPrestacion);
        }
Ejemplo n.º 6
0
        public static List <Prestacion> listaPresentacion()
        {
            List <Prestacion> resultado = new List <Prestacion>();

            string CadenaC = System.Configuration.ConfigurationManager.AppSettings["CadenaConexion"].ToString();
            //creamos una cadena de conexion hacia la base de datos
            SqlConnection cn = new SqlConnection(CadenaC);

            try
            {
                //creamos un comando
                SqlCommand cmd = new SqlCommand();

                string consulta = "SELECT * FROM Prestaciones";
                cmd.Parameters.Clear(); //le limpiamos los parametros

                //se va a ejecutar una accion por usuario por eso es .text como una sentencia sql
                cmd.CommandType = System.Data.CommandType.Text;
                //le pasa cual seria la consulta que en este caso es el insert
                cmd.CommandText = consulta;

                //se abra la conexion
                cn.Open();
                //que el comando tome la conexion con la base de datos
                cmd.Connection = cn;
                //los parametros debe ser correctos

                SqlDataReader dr = cmd.ExecuteReader();


                if (dr != null)
                {
                    while (dr.Read())
                    {
                        Prestacion p = new Prestacion();
                        p.id          = int.Parse(dr["idPrestacion"].ToString());
                        p.descripcion = dr["descripcion"].ToString();



                        resultado.Add(p);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                cn.Close();
            }

            return(resultado);
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("Id,Nombre,DuracionHoras,Monto")] Prestacion prestacion)
        {
            if (ModelState.IsValid)
            {
                _context.Add(prestacion);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(prestacion));
        }
Ejemplo n.º 8
0
        // Función auxiliar responsable de MAPPEAR una fila de Prestacions a un objeto Prestacion
        private Prestacion map_presta(DataRow row)
        {
            Prestacion oPrestacion = new Prestacion();

            oPrestacion.id_prestacion  = Convert.ToInt32(row["id_prestacion"].ToString());
            oPrestacion.cod_prestacion = row["cod_prestacion"].ToString();
            oPrestacion.nombre         = row["nombre"].ToString();
            oPrestacion.descripcion    = row["descripcion"].ToString();

            return(oPrestacion);
        }
Ejemplo n.º 9
0
        public GenericApiResponse <Prestacion> CrearPrestacion([FromBody] Prestacion prestacion)
        {
            contexto.Prestacion.Add(prestacion);
            contexto.SaveChanges();

            GenericApiResponse <Prestacion> response = new GenericApiResponse <Prestacion>();

            response.OK   = true;
            response.Data = prestacion;

            return(response);
        }
Ejemplo n.º 10
0
        public IList <Prestacion> getAll()
        {
            List <Prestacion> lst         = new List <Prestacion>();
            string            sql         = "Select * from Prestaciones ";
            Prestacion        oPrestacion = null /* TODO Change to default(_) if this is not a reference type */;

            foreach (DataRow row in BDHelper.getBDHelper().ConsultaSQL(sql).Rows)
            {
                lst.Add(map_presta(row));
            }

            return(lst);
        }
Ejemplo n.º 11
0
        // Funciones CRUD
        public bool create(Prestacion oPrestacion)
        {
            string str_sql;

            str_sql  = "INSERT INTO Prestaciones ( cod_prestacion, nombre, descripcion) VALUES('";
            str_sql += oPrestacion.cod_prestacion + "','";
            str_sql += oPrestacion.nombre + "','";
            str_sql += oPrestacion.descripcion + "')";
            MessageBox.Show(str_sql);

            // Si una fila es afectada por la inserción retorna TRUE. Caso contrario FALSE
            return(BDHelper.getBDHelper().EjecutarSQL(str_sql) == 1);
        }
Ejemplo n.º 12
0
        public Prestacion getPrestacionBycod(string cod_prestacion)
        {
            string     sql = "Select * from Prestaciones where  cod_prestacion = '" + cod_prestacion + "'";
            DataTable  oTabla;
            Prestacion oPrestacion = null /* TODO Change to default(_) if this is not a reference type */;

            oTabla = BDHelper.getBDHelper().ConsultaSQL(sql);
            if (oTabla.Rows.Count > 0)
            {
                oPrestacion = map_presta(oTabla.Rows[0]);
            }

            return(oPrestacion);
        }
Ejemplo n.º 13
0
        public Prestacion getUserByName(string nombre)
        {
            string     sql = "Select x.* from Prestaciones x where  x.nombre = '" + nombre + "'";
            DataTable  oTabla;
            Prestacion oPrestacion = null /* TODO Change to default(_) if this is not a reference type */;

            oTabla = BDHelper.getBDHelper().ConsultaSQL(sql);
            if (oTabla.Rows.Count > 0)
            {
                oPrestacion = map_user(oTabla.Rows[0]);
            }

            return(oPrestacion);
        }
Ejemplo n.º 14
0
        // Funciones CRUD

        public bool update(Prestacion oPrestacion)
        {
            string str_sql;

            str_sql  = "UPDATE Prestaciones SET cod_prestacion = '";
            str_sql += oPrestacion.cod_prestacion + "', nombre = '";
            str_sql += oPrestacion.nombre + "' , descripcion = '";
            str_sql += oPrestacion.descripcion + "'";
            str_sql += " WHERE id_prestacion = " + oPrestacion.id_prestacion.ToString();

            MessageBox.Show(str_sql);
            // Si una fila es afectada por la actualización retorna TRUE. Caso contrario FALSE
            return(BDHelper.getBDHelper().EjecutarSQL(str_sql) == 1);
        }
Ejemplo n.º 15
0
        public JsonResult Crear(Prestacion prestacion)
        {
            prestacion.Paciente    = Repositorio.Obtener <Paciente>(prestacion.Paciente.Id);
            prestacion.Profesional = Repositorio.Obtener <Profesional>(prestacion.Profesional.Id);
            prestacion.Zona        = Repositorio.Obtener <Zona>(prestacion.Zona.Id);
            var empresadb = Repositorio.Obtener <Prestacion>(new List <Expression <Func <Prestacion, object> > > {
                x => x.Zona, x => x.Profesional, x => x.Visitas.Select(y => y.ProfesionalEfectivo)
            }, x => x.Id == prestacion.Id);

            empresadb.Actualizar(prestacion);
            ActualizarVisitas(empresadb, prestacion);
            prestacion = empresadb;
            Repositorio.GuardarCambios();
            return(Json(prestacion, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 16
0
        public async Task <ActionResult <Prestacion> > PostPrestacion(Prestacion prestacion)
        {
            try
            {
                string logo = null;
                prestacion.ProfesionalId = _context.Usuarios.FirstOrDefault(x => x.Email == User.Identity.Name).Id;
                if (prestacion.Logo != null)
                {
                    logo            = prestacion.Logo;
                    prestacion.Logo = "a";
                }
                _context.Prestaciones.Add(prestacion);
                await _context.SaveChangesAsync();

                if (prestacion.Logo != null)
                {
                    var    prestation = _context.Prestaciones.Last();
                    var    fileName   = "logo.png";
                    string wwwPath    = environment.WebRootPath;
                    string path       = wwwPath + "/logo/" + prestation.Id;
                    string filePath   = "/logo/" + prestation.Id + "/" + fileName;
                    string pathFull   = Path.Combine(path, fileName);

                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }

                    using (var fileStream = new FileStream(pathFull, FileMode.Create))
                    {
                        var bytes = Convert.FromBase64String(logo);
                        fileStream.Write(bytes, 0, bytes.Length);
                        fileStream.Flush();
                        prestation.Logo = filePath;
                    }

                    _context.Prestaciones.Update(prestation);
                    _context.SaveChanges();
                }

                return(CreatedAtAction("GetPrestacion", new { id = prestacion.Id }, prestacion));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Ejemplo n.º 17
0
        // Permite recuperar todos los prestacions cargados para un determinado rango de fechas y/o perfil recibidos como
        // parámetrosr
        public IList <Prestacion> getByFilters(List <object> @params)
        {
            List <Prestacion> lst         = new List <Prestacion>();
            string            sql         = "Select x.* from Prestaciones x ";
            Prestacion        oPrestacion = null /* TODO Change to default(_) if this is not a reference type */;

            if (@params[0] != null)
            {
                sql += " AND x.nombre=@param1 ";
            }


            foreach (DataRow row in BDHelper.getBDHelper().ConsultaSQLConParametros(sql, @params).Rows)
            {
                lst.Add(map_user(row));
            }

            return(lst);
        }
Ejemplo n.º 18
0
 private void ActualizarVisitas(Prestacion p, Prestacion pDto = null)
 {
     if (p.Visitas == null)
     {
         p.Visitas = new List <Visita>();
     }
     if (p.Cantidad > p.Visitas.Count)
     {
         var c = (p.Cantidad - p.Visitas.Count);
         for (var i = 0; i < c; i++)
         {
             p.Visitas.Add(new Visita {
                 Estado = EstadoVisita.Pendiente, Fecha = null, ProfesionalEfectivo = p.Profesional
             });
         }
     }
     else if (p.Cantidad < p.Visitas.Count)
     {
         var c = (p.Visitas.Count - p.Cantidad);
         for (var i = 0; i < c; i++)
         {
             var elemento = p.Visitas.Last();
             p.Visitas.Remove(elemento);
             Repositorio.Remover <Visita>(elemento);
         }
     }
     if (pDto != null)
     {
         foreach (var v in p.Visitas)
         {
             var vDto = pDto.Visitas.FirstOrDefault(x => x.Id == v.Id);
             if (vDto != null)
             {
                 v.ProfesionalEfectivo = Repositorio.Obtener <Profesional>(vDto.ProfesionalEfectivo.Id);
                 v.Estado = vDto.Estado;
                 v.Fecha  = vDto.Fecha;
             }
         }
     }
 }
Ejemplo n.º 19
0
        public IList <Prestacion> getByFilters(List <object> @params)
        {
            List <Prestacion> lst         = new List <Prestacion>();
            string            sql         = "Select * from Prestaciones WHERE";
            Prestacion        oPrestacion = null /* TODO Change to default(_) if this is not a reference type */;

            if (@params[0] != null)
            {
                sql += " cod_prestacion LIKE '%' + @param1 + '%' ";
            }

            if (@params[1] != null)
            {
                sql += " nombre LIKE  @param2 + '%' ";
            }


            foreach (DataRow row in BDHelper.getBDHelper().ConsultaSQLConParametros(sql, @params).Rows)
            {
                lst.Add(map_presta(row));
            }

            return(lst);
        }
 public PrestacionService(Prestacion modelo)
 {
     this.connString = ConfigurationManager.ConnectionStrings["FormularioEntities"].ConnectionString;
     this.modelo     = modelo;
 }
Ejemplo n.º 21
0
 public bool crearPrestacion(Prestacion oPrestacion)
 {
     return(oPrestacionDao.create(oPrestacion));
 }
Ejemplo n.º 22
0
        public async Task <IActionResult> PutServicio([FromBody] Prestacion entidad)
        {
            try
            {
                Prestacion prestacion = null;
                Msj        mensaje    = new Msj();

                if (ModelState.IsValid && _context.Prestaciones.AsNoTracking().SingleOrDefault(e => e.Id == entidad.Id) != null)
                {
                    prestacion             = _context.Prestaciones.SingleOrDefault(x => x.Id == entidad.Id);
                    prestacion.Direccion   = entidad.Direccion;
                    prestacion.Nombre      = entidad.Nombre;
                    prestacion.Telefono    = entidad.Telefono;
                    prestacion.CategoriaId = entidad.CategoriaId;
                    prestacion.Disponible  = entidad.Disponible;

                    _context.Prestaciones.Update(prestacion);
                    _context.SaveChanges();

                    if (entidad.Logo != null)
                    {
                        if (prestacion.Logo != null)
                        {
                            string wwwPath  = environment.WebRootPath;
                            string fullPath = wwwPath + prestacion.Logo;
                            using (var fileStream = new FileStream(fullPath, FileMode.Create))
                            {
                                var bytes = Convert.FromBase64String(entidad.Logo);
                                fileStream.Write(bytes, 0, bytes.Length);
                                fileStream.Flush();
                            }
                        }
                        else
                        {
                            var    fileName = "logo.png";
                            string wwwPath  = environment.WebRootPath;
                            string path     = wwwPath + "/logo/" + prestacion.Id;
                            string filePath = "/logo/" + prestacion.Id + "/" + fileName;
                            string pathFull = Path.Combine(path, fileName);

                            if (!Directory.Exists(path))
                            {
                                Directory.CreateDirectory(path);
                            }

                            using (var fileStream = new FileStream(pathFull, FileMode.Create))
                            {
                                var bytes = Convert.FromBase64String(entidad.Logo);
                                fileStream.Write(bytes, 0, bytes.Length);
                                fileStream.Flush();
                                prestacion.Logo = filePath;
                            }

                            _context.Prestaciones.Update(prestacion);
                            _context.SaveChanges();
                        }
                    }

                    mensaje.Mensaje = "Datos actualizados correctamente!";

                    return(Ok(mensaje));
                }
                return(BadRequest());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
 private decimal CalcularTotal(Prestacion prestacion)
 {
     return(prestacion.Preaviso + prestacion.Cesantia +
            prestacion.Vacaciones + prestacion.SalarioNavidad);
 }
Ejemplo n.º 24
0
 public void seleccionar_prestacion(Opcion op, Prestacion prestacionSelected)
 {
     _action             = op;
     oPrestacionSelected = prestacionSelected;
 }
Ejemplo n.º 25
0
        public void Seed()

        {
            var prestacion = new Prestacion
            {
                Nombre        = "Odontologia General",
                Monto         = 500,
                DuracionHoras = 1
            };
            var prestacion2 = new Prestacion
            {
                Nombre        = "Ortodoncia",
                Monto         = 1000,
                DuracionHoras = 2
            };
            var disponibilidad = new Disponibilidad(9, 23, DiasEnum.Sabado);

            var direCentro = new Direccion
            {
                Calle     = "La famosa",
                Altura    = 321,
                Localidad = "Escobar",
                Provincia = "BUENOS AIRES"
            };
            var centro1 = new Centro
            {
                Direccion = direCentro,
                Nombre    = "The best centro",
            };
            var direPaciente1 = new Direccion
            {
                Calle     = "Aristobulo del valle2",
                Altura    = 285,
                Localidad = "CABA",
                Provincia = "BUENOS AIRES"
            };
            var direPaciente2 = new Direccion
            {
                Calle     = "Calle falsa",
                Altura    = 123,
                Localidad = "CABA",
                Provincia = "BUENOS AIRES"
            };
            var direProf = new Direccion
            {
                Calle     = "Calle falsedad",
                Altura    = 13323,
                Localidad = "CABA",
                Provincia = "BUENOS AIRES"
            };
            var direAdmin = new Direccion
            {
                Calle     = "Calle delAdmin",
                Altura    = 1323,
                Localidad = "CABA",
                Provincia = "BUENOS AIRES"
            };

            var tel1 = new Telefono
            {
                NumeroCelular       = "111122222",
                TelefonoAlternativo = "456456456"
            };
            var tel2 = new Telefono
            {
                NumeroCelular       = "1111222223",
                TelefonoAlternativo = "4564564563"
            };
            var tel3 = new Telefono
            {
                NumeroCelular       = "1113332223",
                TelefonoAlternativo = "45634564563"
            };
            var tel4 = new Telefono
            {
                NumeroCelular       = "1111222223",
                TelefonoAlternativo = "4564564563"
            };
            var mail1 = new Mail
            {
                Descripcion = "*****@*****.**"
            };
            var mail2 = new Mail
            {
                Descripcion = "*****@*****.**"
            };
            var mail3 = new Mail
            {
                Descripcion = "*****@*****.**"
            };
            var mail4 = new Mail
            {
                Descripcion = "*****@*****.**"
            };


            var profesional = new Profesional
            {
                Nombre           = "Roberto",
                Apellido         = "Garcia",
                Centro           = centro1,
                Dni              = "123123123",
                Prestacion       = prestacion2,
                Rol              = RolesEnum.PROFESIONAL,
                Mails            = new List <Mail>(),
                Turnos           = new List <Turno>(),
                Telefonos        = new List <Telefono>(),
                Direcciones      = new List <Direccion>(),
                Disponibilidades = new List <Disponibilidad>(),
                Username         = "******",
                Password         = "******".Encriptar()
            };
            var profesional2 = new Profesional
            {
                Nombre           = "Checho",
                Apellido         = "Palavecino",
                Centro           = centro1,
                Dni              = "999999999",
                Prestacion       = prestacion,
                Rol              = RolesEnum.PROFESIONAL,
                Mails            = new List <Mail>(),
                Turnos           = new List <Turno>(),
                Telefonos        = new List <Telefono>(),
                Direcciones      = new List <Direccion>(),
                Disponibilidades = new List <Disponibilidad>(),
                Username         = "******",
                Password         = "******".Encriptar()
            };
            var administrador = new Administrador
            {
                Nombre      = "Cristofer",
                Apellido    = "Wallace",
                Dni         = "00000000001",
                Rol         = RolesEnum.ADMINISTRADOR,
                Mails       = new List <Mail>(),
                Telefonos   = new List <Telefono>(),
                Direcciones = new List <Direccion>(),
                Username    = "******",
                Password    = "******".Encriptar()
            };
            var paciente = new Paciente
            {
                Nombre      = "Pepe",
                Apellido    = "Paciente",
                Dni         = "123123123",
                Rol         = RolesEnum.CLIENTE,
                Direcciones = new List <Direccion>(),
                Mails       = new List <Mail>(),
                Telefonos   = new List <Telefono>(),
                Turnos      = new List <Turno>(),
                Username    = "******",
                Password    = "******".Encriptar()
            };
            var paciente2 = new Paciente
            {
                Nombre      = "Pepe2",
                Apellido    = "Paciente2",
                Dni         = "123123123",
                Rol         = RolesEnum.CLIENTE,
                Direcciones = new List <Direccion>(),
                Mails       = new List <Mail>(),
                Telefonos   = new List <Telefono>(),
                Turnos      = new List <Turno>(),
                Username    = "******",
                Password    = "******".Encriptar()
            };

            administrador.Mails.Add(mail4);
            administrador.Telefonos.Add(tel4);
            administrador.Direcciones.Add(direAdmin);

            profesional.Mails.Add(mail1);
            profesional.Telefonos.Add(tel1);
            profesional.Direcciones.Add(direProf);
            profesional.Disponibilidades.Add(disponibilidad);

            paciente.Telefonos.Add(tel2);
            paciente.Mails.Add(mail2);
            paciente2.Mails.Add(mail3);
            paciente.Direcciones.Add(direPaciente1);
            paciente2.Telefonos.Add(tel3);
            paciente2.Direcciones.Add(direPaciente2);

            _context.Pacientes.Add(paciente);
            _context.Pacientes.Add(paciente2);
            _context.Profesionales.Add(profesional);
            _context.Profesionales.Add(profesional2);
            _context.Administradores.Add(administrador);
            _context.SaveChanges();

            /*      if (!_context.Prestaciones.Any())
             *    {
             *
             *        _context.Add(prestacion);
             *        _context.SaveChanges();
             *
             *    } */
        }
Ejemplo n.º 26
0
 public bool modificarEstadoPrestacion(Prestacion oPrestacion)
 {
     return(oPrestacionDao.update(oPrestacion));
 }
Ejemplo n.º 27
0
 public bool actualizarPrestacion(Prestacion oPrestacion)
 {
     return(oPrestacionDao.update(oPrestacion));
 }
Ejemplo n.º 28
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            string     str_sql = "";
            Prestacion oPrestacion;

            switch (_action)
            {
            case Opcion.insert:
            {
                if (existe_nombre() == false)
                {
                    if (validar_campos())
                    {
                        oPrestacion                = new Prestacion();
                        oPrestacion.nombre         = txtNombre.Text;
                        oPrestacion.cod_prestacion = txtCodigoPrestacion.Text;
                        oPrestacion.descripcion    = txtDescripcion.Text;

                        if (oPrestacionService.crearPrestacion(oPrestacion))
                        {
                            MessageBox.Show("Prestacion insertado correctamente!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Close();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Nombre de la prestacion  encontrado!. Ingrese un nombre diferente", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                break;
            }

            case Opcion.update:
            {
                if (validar_campos())
                {
                    oPrestacionSelected.nombre         = txtNombre.Text;
                    oPrestacionSelected.cod_prestacion = txtCodigoPrestacion.Text;
                    oPrestacionSelected.descripcion    = txtDescripcion.Text;

                    if (oPrestacionService.actualizarPrestacion(oPrestacionSelected))
                    {
                        MessageBox.Show("Prestacion actualizada! ", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Dispose();
                    }
                    else
                    {
                        MessageBox.Show("Error al actualizar la prestacion! ", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                break;
            }

            case Opcion.delete:
            {
                if (MessageBox.Show("Seguro que desea deshabilitar el usuario seleccionado?", "Aviso", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    oPrestacionSelected.nombre         = txtNombre.Text;
                    oPrestacionSelected.cod_prestacion = txtCodigoPrestacion.Text;
                    oPrestacionSelected.descripcion    = txtDescripcion.Text;

                    if (oPrestacionService.modificarEstadoPrestacion(oPrestacionSelected))
                    {
                        MessageBox.Show("prestacion Deshabilitada!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Dispose();
                    }
                    else
                    {
                        MessageBox.Show("Error al actualizar la prestacion!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                break;
            }
            }
        }
Ejemplo n.º 29
0
        public Afiliado Elegibilidad(Elegibilidad model)
        {
            try
            {
                var prestador = new PrestadorRepository();
                var matricula = 0;
                switch (model.OsId)
                {
                case 0:
                    break;

                case 1:    //Swiss Medical
                    var swiss = new OSSwiss();
                    return(swiss.Eligibilidad(model.Credencial));

                case 2:
                    var acaSalud = new OSAcaSalud();

                    matricula = prestador.GetMatriculaFromIdPre(model.IdPre);
                    return(acaSalud.Elegibilidad(model.Credencial, matricula));

                case 3:
                    break;

                case 4:
                    break;

                case 5:
                case 8:
                    var boreal = new OSBoreal();
                    return(boreal.Eligibilidad(model.Credencial));

                case 6:
                    var medife = new OSMedife();
                    return(medife.Eligibilidad(model.Credencial));

                case 7:
                    var redSeguros = new OSRedSeguros();
                    return(redSeguros.Eligibilidad(model.Credencial));

                case 9:
                    var sancor = new OSSancor();
                    matricula = prestador.GetMatriculaFromIdPre(model.IdPre);
                    return(sancor.Elegibilidad(model.Credencial));

                case 10:
                    var lyf   = new OSLuzFuerza();
                    var datos = prestador.GetInfoFromIdPre(model.IdPre);

                    Afiliado afiliado = lyf.Eligibilidad(model.Credencial, Convert.ToInt32(datos.Matricula)).Result;
                    if (!afiliado.HasError)
                    {
                        Authorize autoriza = new Authorize(model.OsId, model.IdPre, model.IdPre, model.Credencial, string.Empty, new List <Prestacion>(), model.UserId);

                        autoriza.AfiliadoNombre = afiliado.Name;
                        autoriza.AfiliadoPlan   = "";

                        autoriza.Efector           = new Efector();
                        autoriza.Efector.Matricula = matricula;
                        autoriza.Efector.Name      = datos.Name;

                        autoriza.Prestaciones = new List <Prestacion>();
                        var presta = new Prestacion();
                        presta.Cant        = 1;
                        presta.CodPres     = "420101";
                        presta.Descripcion = "CONSULTA MEDICA";

                        autoriza.Prestaciones.Add(presta);

                        var autorizacionOs = lyf.Autorizar(autoriza, afiliado.Plan);

                        if (!autorizacionOs.HasError)
                        {
                            var autorizacionRepository = new AutorizacionRepository();
                            var authNr = autorizacionRepository.Autorizar(autorizacionOs);
                            afiliado.Nr = authNr.ToString();
                        }
                    }
                    else
                    {
                        if (afiliado.Name == "afiliado inexistente")
                        {
                            afiliado.HasError = false;
                        }
                        else
                        {
                            if (afiliado.Name == "afiliado con 2 consultas realizadas en el mes")
                            {
                                afiliado.Name = "El afiliado supero el límite de consumo mensual. Por favor digerirse a las oficinas de la Obra Social para la autorización de la práctica. ";
                            }
                            else
                            {
                                if (afiliado.Name != "Error el formato del carnet es incorrecto! Ej. xx-xxxxx-x/xx")
                                {
                                    afiliado.SetError(GetType().Name, 0, "Luz y Fuerza: " + afiliado.Name, string.Empty, model.Credencial + ";" + datos.Matricula, string.Empty);
                                    afiliado.Name = "Se ha producido un error desconocido. Por favor comunicarse con el Área de Sistemas del Circulo Medico de Salta";
                                }
                            }
                        }
                    }

                    afiliado.Plan = "";
                    return(afiliado);
                    //case 11:
                    //    var os = new OSOspatrones();
                    //    matricula = prestador.GetMatriculaFromIdPre(model.IdPre);
                    //    return os.Eligibilidad(model.Credencial, matricula);
                }
            }
            catch (Exception ex)
            {
                var errors = new Errores();
                errors.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? string.Empty, model, string.Empty);
            }
            return(new Afiliado());
        }