예제 #1
0
        public IActionResult Search(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(RedirectToAction("Index"));
            }
            ViewData["controller"] = "Personas";
            ViewData["action"]     = "Buscar";

            var personasList = _personaRepository.Get(x => x.Apellidos.ToLower().Contains(id.ToLower()) || x.Cedula.Contains(id) || x.Nombres.ToLower().Contains(id.ToLower()) ||
                                                      x.CorreoElectronico.ToLower().Contains(id.ToLower()) || x.Banco.ToLower().Contains(id.ToLower()));
            var search = ParseToListMVC(personasList);

            return(View(search.ToList()));
        }
예제 #2
0
 public IList <Persona> Get()
 {
     try
     {
         return(repository.Get());
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
예제 #3
0
 public async Task <Persona> Get(int id)
 {
     return(await _personaRepository.Get(id));
 }
예제 #4
0
        public AlertsPartialModel(DbContextOptions <FondoContext> dbContext) : base()
        {
            int countAlerts = 0;
            var hoy         = DateTime.Today;

            _dbContext              = dbContext;
            _personaRepository      = new PersonaRepository(_dbContext);
            _prestamoRepository     = new PrestamoRepository(_dbContext);
            _consignacionRepository = new ConsignacionRepository(_dbContext);
            var afiliadosActivos = _personaRepository.Get(x => x.Activo && x.Afiliado, new string[] { "Consignaciones", "Prestamos" });

            foreach (var afiliado in afiliadosActivos)
            {
                var ultimaConsignacion = afiliado.Consignaciones.Where(x => x.TipoConsignacion == 2).LastOrDefault();
                var diffDias           = 0;
                if (ultimaConsignacion != null)
                {
                    diffDias = ((TimeSpan)(hoy - ultimaConsignacion.Fecha)).Days;
                }
                if (ultimaConsignacion == null && (hoy.Month > 1 || (afiliado.Quincena.Value == 1 && hoy.Day > 5) || (afiliado.Quincena.Value == 2 && hoy.Day > 15)))
                {
                    countAlerts++;
                }
                else if (diffDias > 30)
                {
                    countAlerts++;
                }
                else if (afiliado.Quincena.HasValue && (afiliado.Quincena.Value == 1 && diffDias > 5) || (afiliado.Quincena.Value == 2 && diffDias > 15))
                {
                    countAlerts++;
                }
            }
            NumberAlertsAhorro = countAlerts;
            countAlerts        = 0;
            var prestamosActivos = _prestamoRepository.Get(x => !x.Finalizado, new string[] { "Persona" });

            foreach (var prestamo in prestamosActivos)
            {
                var diffDias     = 0;
                var fechaLimite  = new DateTime(hoy.Year, hoy.Month, prestamo.Fecha.Day);
                var consignacion = _consignacionRepository.Get(x => x.PersonaId == prestamo.PersonaId && x.TipoConsignacion == 1 && x.Interes.HasValue && x.Interes > 0).LastOrDefault();
                if (consignacion != null)
                {
                    diffDias = ((TimeSpan)(fechaLimite - consignacion.Fecha)).Days;
                    if (diffDias > 30)
                    {
                        countAlerts++;
                    }
                }
                else
                {
                    diffDias = ((TimeSpan)(fechaLimite - prestamo.Fecha)).Days;
                    if (diffDias > 30)
                    {
                        countAlerts++;
                    }
                }
            }
            NumberAlertsPrestamo = countAlerts;
            NumberAlertsTotal    = NumberAlertsPrestamo + NumberAlertsAhorro;
        }