Beispiel #1
0
        public HttpResponseMessage Post(Estatus_de_Pago varEstatus_de_Pago)
        {
            if (ModelState.IsValid)
            {
                var data = "-1";
                try
                {
                    data = Convert.ToString(this.service.Insert(varEstatus_de_Pago));
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsEstatus_de_Pago", new JavaScriptSerializer().Serialize(varEstatus_de_Pago), true);
                    serviceBitacora.Insert(bitacora);
                }
                catch (ServiceException ex)
                {
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsEstatus_de_Pago", new JavaScriptSerializer().Serialize(varEstatus_de_Pago), true);
                    serviceBitacora.Insert(bitacora);
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
            }
            else
            {
                var errors   = ModelState.SelectMany(m => m.Value.Errors.Select(err => err.ErrorMessage != string.Empty ? err.ErrorMessage : err.Exception.Message).ToList()).ToList();
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsEstatus_de_Pago", new JavaScriptSerializer().Serialize(varEstatus_de_Pago), false, errors.ToString());
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
        }
Beispiel #2
0
        public HttpResponseMessage Delete(int id)
        {
            Estatus_de_Pago varEstatus_de_Pago = this.service.GetByKey(id, false);
            bool            result             = false;

            if (varEstatus_de_Pago == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            try
            {
                result = this.service.Delete(id);//, globalData, dataReference);
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelEstatus_de_Pago", new JavaScriptSerializer().Serialize(varEstatus_de_Pago), result);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelEstatus_de_Pago", new JavaScriptSerializer().Serialize(varEstatus_de_Pago), result, ex.Message);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
        public ActionResult Post(bool IsNew, Estatus_de_PagoModel varEstatus_de_Pago)
        {
            try
            {
                //if (ModelState.IsValid)
                //{
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _IEstatus_de_PagoApiConsumer.SetAuthHeader(_tokenManager.Token);



                var result = "";
                var Estatus_de_PagoInfo = new Estatus_de_Pago
                {
                    Clave         = varEstatus_de_Pago.Clave
                    , Descripcion = varEstatus_de_Pago.Descripcion
                };

                result = !IsNew?
                         _IEstatus_de_PagoApiConsumer.Update(Estatus_de_PagoInfo, null, null).Resource.ToString() :
                             _IEstatus_de_PagoApiConsumer.Insert(Estatus_de_PagoInfo, null, null).Resource.ToString();

                Session["KeyValueInserted"] = result;
                return(Json(result, JsonRequestBehavior.AllowGet));
                //}
                //return Json(false, JsonRequestBehavior.AllowGet);
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #4
0
        public HttpResponseMessage Get_Datos_Generales(int id)
        {
            Estatus_de_Pago entity = this.service.ListaSelAll(1, 1, "Estatus_de_Pago.Clave='" + id.ToString() + "'", "").Estatus_de_Pagos.First();
            Estatus_de_Pago result = new Estatus_de_Pago();

            result.Clave       = entity.Clave;
            result.Descripcion = entity.Descripcion;

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
Beispiel #5
0
        public HttpResponseMessage PutTunnel(Estatus_de_Pago emp, string user, string password)
        {
            var client = new System.Net.WebClient();

            client.Headers = TokenManager.GetAuthenticationHeader(user, password);
            client.Headers["Content-Type"] = "application/json";
            var dataString = new JavaScriptSerializer().Serialize(emp);

            var result = client.UploadString(new Uri(baseApi + ApiControllerUrl + "/Put?Id=" + emp.Clave), "PUT"
                                             , dataString);

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
Beispiel #6
0
        public HttpResponseMessage Put_Datos_Generales(Estatus_de_Pago varEstatus_de_Pago_Datos_Generales)
        {
            var data = "-1";

            try
            {
                data = Convert.ToString(this.service.Update_Datos_Generales(varEstatus_de_Pago_Datos_Generales));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varEstatus_de_Pago_Datos_Generales.Clave, BitacoraHelper.TypeSql.UPDATE, "sp_UpdEstatus_de_Pago", new JavaScriptSerializer().Serialize(varEstatus_de_Pago_Datos_Generales), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varEstatus_de_Pago_Datos_Generales.Clave, BitacoraHelper.TypeSql.UPDATE, "sp_UpdEstatus_de_Pago", new JavaScriptSerializer().Serialize(varEstatus_de_Pago_Datos_Generales), false, ex.Message);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
Beispiel #7
0
        public HttpResponseMessage Estatus_de_PagoGenerateID()
        {
            Estatus_de_Pago varEstatus_de_Pago = new Estatus_de_Pago();
            var             data = "-1";

            try
            {
                data = Convert.ToString(this.service.Insert(varEstatus_de_Pago));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_Estatus_de_PagoGenerateID", new JavaScriptSerializer().Serialize(varEstatus_de_Pago), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_Estatus_de_PagoGenerateID", new JavaScriptSerializer().Serialize(varEstatus_de_Pago), true);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
        public ActionResult Delete(int id)
        {
            try
            {
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _IEstatus_de_PagoApiConsumer.SetAuthHeader(_tokenManager.Token);

                Estatus_de_Pago varEstatus_de_Pago = null;
                if (id.ToString() != "0")
                {
                    string where = "";
                }
                var result = _IEstatus_de_PagoApiConsumer.Delete(id, null, null).Resource;
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }