// GET: Personas/Details/5 public async Task <IActionResult> Details(int?id) { ViewData["controller"] = "Personas"; ViewData["action"] = "Detalles"; if (id == null) { return(NotFound()); } var persona = await _personaRepository.GetByIdAsync(x => x.Id == id.Value, new string[] { "Prestamos", "Consignaciones" }); if (persona == null) { return(NotFound()); } ViewBag.totalAhorrado = persona.Consignaciones.Where(x => x.TipoConsignacion == 2).Sum(x => x.Valor); ViewBag.prestamo = persona.Prestamos.Where(x => !x.Finalizado).Select(x => x.Valor).FirstOrDefault(); ViewBag.abonado = persona.Consignaciones.Where(x => x.TipoConsignacion == 1).Sum(x => x.Valor); ViewBag.saldo = ViewBag.prestamo - ViewBag.abonado; ViewBag.montoAhorro = string.Format("{0:c}", persona.MontoAhorro); return(View(ParseToMVC(persona))); }
public async Task <JsonResult> MontoAhorroAsync(int id) { var cliente = await _personaRepository.GetByIdAsync(id); var ahorro = cliente.MontoAhorro; return(new JsonResult(ahorro)); }