public JsonResult PagarDeuda(int deuId)
        {
            try
            {
                var deuda = BDD.TBL_DEUDA.FirstOrDefault(o => o.DEU_ID == deuId);

                var pago = new TBL_PAGOS
                {
                    CLI_ID       = deuda.CLI_ID ?? 0,
                    PAG_FECHA    = DateTime.Now,
                    PAG_MONTO    = deuda.DEU_DEUDA + deuda.DEU_MULTA ?? 0,
                    PAG_VIGENCIA = true,
                };

                BDD.TBL_PAGOS.Add(pago);
                BDD.Entry(pago).State = System.Data.Entity.EntityState.Added;

                BDD.SaveChanges();

                deuda.DEU_CHECK = true;
                deuda.PAG_ID    = pago.PAG_ID;

                BDD.TBL_DEUDA.Attach(deuda);
                BDD.Entry(deuda).State = System.Data.Entity.EntityState.Modified;

                BDD.SaveChanges();

                return(JsonExito("Deuda pagada con éxito."));
            }
            catch (Exception ex)
            {
                Logger(ex);
                return(JsonError("No se ha podido pagar la deuda."));
            }
        }
Beispiel #2
0
        public static async Task <bool> savePago(TBL_PAGOS _infoPago, EcommerceEntities dbEstatica)
        {
            try
            {
                bool resultado = false;
                _infoPago.PAG_ESTADO         = "A";
                _infoPago.PAG_FECHA_CREACION = DateTime.Now;
                _infoPago.PAG_FECHA          = DateTime.Now;
                _infoPago.PED_FECHA          = DateTime.Now;
                dbEstatica.TBL_PAGOS.Add(_infoPago);

                //Actualizar Datos
                await dbEstatica.SaveChangesAsync();

                resultado = true;
                return(resultado);
            }
            catch (Exception ex)
            {
                throw new ArgumentException("Error : " + ex.Message);
            }
        }
Beispiel #3
0
        private void savePago(TBL_PEDIDO _infoPedido, string valorPago, string formaPago, EcommerceEntities dbEstatica)
        {
            try
            {
                TBL_PAGOS _infoPago = new TBL_PAGOS();
                _infoPago.PED_ID    = _infoPedido.PED_ID;
                _infoPago.PAG_VALOR = Convert.ToDecimal(valorPago);
                _infoPago.FPA_ID    = Convert.ToInt32(formaPago);

                Task <bool> _taskSave = Task.Run(() => LogicaCliente.savePago(_infoPago, dbEstatica));
                _taskSave.Wait();
                var resultado = _taskSave.Result;
                if (!resultado)
                {
                    throw new ArgumentException("No se guardado Pago");
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException("Error: " + ex.Message);
            }
        }