public HttpResponseMessage Post(Formas_de_Pago varFormas_de_Pago) { if (ModelState.IsValid) { var data = "-1"; try { data = Convert.ToString(this.service.Insert(varFormas_de_Pago)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsFormas_de_Pago", new JavaScriptSerializer().Serialize(varFormas_de_Pago), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsFormas_de_Pago", new JavaScriptSerializer().Serialize(varFormas_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_InsFormas_de_Pago", new JavaScriptSerializer().Serialize(varFormas_de_Pago), false, errors.ToString()); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.BadRequest, errors)); } }
public HttpResponseMessage Delete(int id) { Formas_de_Pago varFormas_de_Pago = this.service.GetByKey(id, false); bool result = false; if (varFormas_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_DelFormas_de_Pago", new JavaScriptSerializer().Serialize(varFormas_de_Pago), result); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelFormas_de_Pago", new JavaScriptSerializer().Serialize(varFormas_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, Formas_de_PagoModel varFormas_de_Pago) { try { //if (ModelState.IsValid) //{ if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IFormas_de_PagoApiConsumer.SetAuthHeader(_tokenManager.Token); var result = ""; var Formas_de_PagoInfo = new Formas_de_Pago { Clave = varFormas_de_Pago.Clave , Nombre = varFormas_de_Pago.Nombre }; result = !IsNew? _IFormas_de_PagoApiConsumer.Update(Formas_de_PagoInfo, null, null).Resource.ToString() : _IFormas_de_PagoApiConsumer.Insert(Formas_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)); } }
public HttpResponseMessage Get_Datos_Generales(int id) { Formas_de_Pago entity = this.service.ListaSelAll(1, 1, "Formas_de_Pago.Clave='" + id.ToString() + "'", "").Formas_de_Pagos.First(); Formas_de_Pago result = new Formas_de_Pago(); result.Clave = entity.Clave; result.Nombre = entity.Nombre; return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter)); }
public HttpResponseMessage PutTunnel(Formas_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)); }
public HttpResponseMessage Put_Datos_Generales(Formas_de_Pago varFormas_de_Pago_Datos_Generales) { var data = "-1"; try { data = Convert.ToString(this.service.Update_Datos_Generales(varFormas_de_Pago_Datos_Generales)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varFormas_de_Pago_Datos_Generales.Clave, BitacoraHelper.TypeSql.UPDATE, "sp_UpdFormas_de_Pago", new JavaScriptSerializer().Serialize(varFormas_de_Pago_Datos_Generales), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varFormas_de_Pago_Datos_Generales.Clave, BitacoraHelper.TypeSql.UPDATE, "sp_UpdFormas_de_Pago", new JavaScriptSerializer().Serialize(varFormas_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)); }
public HttpResponseMessage Formas_de_PagoGenerateID() { Formas_de_Pago varFormas_de_Pago = new Formas_de_Pago(); var data = "-1"; try { data = Convert.ToString(this.service.Insert(varFormas_de_Pago)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_Formas_de_PagoGenerateID", new JavaScriptSerializer().Serialize(varFormas_de_Pago), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_Formas_de_PagoGenerateID", new JavaScriptSerializer().Serialize(varFormas_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)); } _IFormas_de_PagoApiConsumer.SetAuthHeader(_tokenManager.Token); Formas_de_Pago varFormas_de_Pago = null; if (id.ToString() != "0") { string where = ""; } var result = _IFormas_de_PagoApiConsumer.Delete(id, null, null).Resource; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }