Exemple #1
0
        public TIPOPAGO GetTipoPagoByID(int id)
        {
            TIPOPAGO otipopago = null;

            try
            {
                using (MyContext ctx = new MyContext())
                {
                    ctx.Configuration.LazyLoadingEnabled = false;
                    otipopago = ctx.TIPOPAGO.Find(id);
                }

                return(otipopago);
            }
            catch (DbUpdateException dbEx)
            {
                string mensaje = "";
                Log.Error(dbEx, System.Reflection.MethodBase.GetCurrentMethod(), ref mensaje);
                throw new Exception(mensaje);
            }
            catch (Exception ex)
            {
                string mensaje = "";
                Log.Error(ex, System.Reflection.MethodBase.GetCurrentMethod(), ref mensaje);
                throw;
            }
        }
Exemple #2
0
        public ActionResult Edit(int id)
        {
            ServiceTipoPago _serviceTipoPago = new ServiceTipoPago();
            TIPOPAGO        otipopago        = null;

            try
            {
                // Si va null
                if (id == null)
                {
                    return(RedirectToAction("Ubicaciones"));
                }

                otipopago = _serviceTipoPago.GetTipoPagoByID(id);
                if (otipopago == null)
                {
                    TempData["Message"]         = "No existe la ubicación solicitada";
                    TempData["Redirect"]        = "TipoPago";
                    TempData["Redirect-Action"] = "TiposPagos";

                    return(RedirectToAction("Default", "Error"));
                }

                return(View(otipopago));
            }
            catch (Exception ex)
            {
                Log.Error(ex, MethodBase.GetCurrentMethod());
                TempData["Message"]         = "Error al procesar los datos" + ex.Message;
                TempData["Redirect"]        = "TipoPago";
                TempData["Redirect-Action"] = "TiposPagos";

                return(RedirectToAction("Default", "Error"));
            }
        }
Exemple #3
0
        public ActionResult Save(TIPOPAGO tp)
        {
            ServiceTipoPago _serviceTipoPago = new ServiceTipoPago();

            try
            {
                if (ModelState.IsValid)
                {
                    TIPOPAGO otipopago = _serviceTipoPago.Save(tp);
                }
                else
                {
                    Util.Util.ValidateErrors(this);

                    return(View("Create", tp));
                }

                return(RedirectToAction("TiposPagos"));
            }
            catch (Exception ex)
            {
                Log.Error(ex, MethodBase.GetCurrentMethod());
                TempData["Message"]         = "Error al procesar los datos" + ex.Message;
                TempData["Redirect"]        = "TipoPago";
                TempData["Redirect-Action"] = "TiposPagos";

                return(RedirectToAction("Default", "Error"));
            }
        }
Exemple #4
0
        public TIPOPAGO Save(TIPOPAGO tipopago)
        {
            int      retorno   = 0;
            TIPOPAGO otipopago = null;

            try
            {
                using (MyContext ctx = new MyContext())
                {
                    ctx.Configuration.LazyLoadingEnabled = false;
                    otipopago = GetTipoPagoByID(tipopago.Id);

                    if (otipopago == null)
                    {
                        ctx.TIPOPAGO.Add(tipopago);
                        retorno = ctx.SaveChanges();
                    }
                    else
                    {
                        ctx.TIPOPAGO.Add(tipopago);
                        ctx.Entry(tipopago).State = EntityState.Modified;
                        retorno = ctx.SaveChanges();
                    }
                }

                if (retorno >= 0)
                {
                    otipopago = GetTipoPagoByID(tipopago.Id);
                }

                return(otipopago);
            }
            catch (DbUpdateException dbEx)
            {
                string mensaje = "";
                Log.Error(dbEx, System.Reflection.MethodBase.GetCurrentMethod(), ref mensaje);
                throw new Exception(mensaje);
            }
            catch (Exception ex)
            {
                string mensaje = "";
                Log.Error(ex, System.Reflection.MethodBase.GetCurrentMethod(), ref mensaje);
                throw;
            }
        }
        public IHttpActionResult ActualizarTipoPago(TIPOPAGO model)
        {
            ResponseModelObj rmO = new ResponseModelObj();

            try
            {
                var response = db.TIPOPAGO.Where(c => c.IdTipoPago == model.IdTipoPago).FirstOrDefault();

                response.DescPago   = model.DescPago;
                response.EstadoPago = model.EstadoPago;

                db.Entry(response).CurrentValues.SetValues(response);
                db.SaveChanges();

                rmO.Success = true;
                rmO.Object  = response;
            }
            catch (Exception e)
            {
                rmO.Message = e.Message;
            }
            return(Ok(rmO));
        }
        public TIPOPAGO Save(TIPOPAGO tipopago)
        {
            IRepositoryTipoPago repository = new RepositoryTipoPago();

            return(repository.Save(tipopago));
        }