public async Task <IActionResult> MarcarPago([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            PagoEntity pago = _context.Pago.Where(p => p.id == id).FirstOrDefault();

            if (pago.Pagado == true)
            {
                pago.Pagado = false;
            }
            else
            {
                pago.Pagado = true;
            }

            try
            {
                _context.Update(pago);
                await _context.SaveChangesAsync();

                ValeEntity vale = _context.Vale.Where(v => v.id == pago.Valeid).FirstOrDefault();

                List <PagoEntity> pagos = await _context.Pago
                                          .Where(p => p.Valeid == pago.Valeid && p.Pagado == true)
                                          .ToListAsync();

                if (pagos.Count == vale.CantidadPagos)
                {
                    vale.Pagado = true;
                }
                else
                {
                    vale.Pagado = false;
                }

                _context.Update(vale);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PagoEntityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PostPagoEntity([FromBody] PagoEntity pagoEntity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Pago.Add(pagoEntity);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPagoEntity", new { id = pagoEntity.id }, pagoEntity));
        }
        public async Task <IActionResult> MarcarPagado(int id, int?navId,
                                                       [Bind("id,Cantidad,FechaLimite,Pagado,Valeid")]
                                                       PagoEntity pagoEntity)
        {
            if (id != pagoEntity.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (pagoEntity.Pagado == false)
                    {
                        pagoEntity.Pagado = true;
                    }
                    else
                    {
                        pagoEntity.Pagado = false;
                    }

                    _context.Update(pagoEntity);
                    await _context.SaveChangesAsync();

                    ValeEntity vale = _context.Vale.Where(v => v.id == pagoEntity.Valeid).FirstOrDefault();

                    List <PagoEntity> pagos = await _context.Pago
                                              .Where(p => p.Valeid == pagoEntity.Valeid && p.Pagado == true)
                                              .ToListAsync();

                    if (pagos.Count == vale.CantidadPagos)
                    {
                        vale.Pagado = true;
                    }
                    else
                    {
                        vale.Pagado = false;
                    }

                    _context.Update(vale);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ValeEntityExists(pagoEntity.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                Debug.WriteLine("NAVID");
                Debug.WriteLine(navId);

                if (navId == 1)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    return(RedirectToAction("VerPagos/" + pagoEntity.Valeid));
                }
            }
            return(View(pagoEntity));
        }