public HttpResponseMessage Post(Duracion_de_Planes_de_Suscripcion varDuracion_de_Planes_de_Suscripcion) { if (ModelState.IsValid) { var data = "-1"; try { data = Convert.ToString(this.service.Insert(varDuracion_de_Planes_de_Suscripcion)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsDuracion_de_Planes_de_Suscripcion", new JavaScriptSerializer().Serialize(varDuracion_de_Planes_de_Suscripcion), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsDuracion_de_Planes_de_Suscripcion", new JavaScriptSerializer().Serialize(varDuracion_de_Planes_de_Suscripcion), 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_InsDuracion_de_Planes_de_Suscripcion", new JavaScriptSerializer().Serialize(varDuracion_de_Planes_de_Suscripcion), false, errors.ToString()); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.BadRequest, errors)); } }
public HttpResponseMessage Delete(int id) { Duracion_de_Planes_de_Suscripcion varDuracion_de_Planes_de_Suscripcion = this.service.GetByKey(id, false); bool result = false; if (varDuracion_de_Planes_de_Suscripcion == 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_DelDuracion_de_Planes_de_Suscripcion", new JavaScriptSerializer().Serialize(varDuracion_de_Planes_de_Suscripcion), result); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelDuracion_de_Planes_de_Suscripcion", new JavaScriptSerializer().Serialize(varDuracion_de_Planes_de_Suscripcion), result, ex.Message); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public HttpResponseMessage Get_Datos_Generales(int id) { Duracion_de_Planes_de_Suscripcion entity = this.service.ListaSelAll(1, 1, "Duracion_de_Planes_de_Suscripcion.Clave='" + id.ToString() + "'", "").Duracion_de_Planes_de_Suscripcions.First(); Duracion_de_Planes_de_Suscripcion result = new Duracion_de_Planes_de_Suscripcion(); result.Clave = entity.Clave; result.Nombre = entity.Nombre; result.Cantidad_en_Meses = entity.Cantidad_en_Meses; result.Cantidad_en_Dias = entity.Cantidad_en_Dias; return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter)); }
public HttpResponseMessage PutTunnel(Duracion_de_Planes_de_Suscripcion 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(Duracion_de_Planes_de_Suscripcion varDuracion_de_Planes_de_Suscripcion_Datos_Generales) { var data = "-1"; try { data = Convert.ToString(this.service.Update_Datos_Generales(varDuracion_de_Planes_de_Suscripcion_Datos_Generales)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varDuracion_de_Planes_de_Suscripcion_Datos_Generales.Clave, BitacoraHelper.TypeSql.UPDATE, "sp_UpdDuracion_de_Planes_de_Suscripcion", new JavaScriptSerializer().Serialize(varDuracion_de_Planes_de_Suscripcion_Datos_Generales), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varDuracion_de_Planes_de_Suscripcion_Datos_Generales.Clave, BitacoraHelper.TypeSql.UPDATE, "sp_UpdDuracion_de_Planes_de_Suscripcion", new JavaScriptSerializer().Serialize(varDuracion_de_Planes_de_Suscripcion_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 Duracion_de_Planes_de_SuscripcionGenerateID() { Duracion_de_Planes_de_Suscripcion varDuracion_de_Planes_de_Suscripcion = new Duracion_de_Planes_de_Suscripcion(); var data = "-1"; try { data = Convert.ToString(this.service.Insert(varDuracion_de_Planes_de_Suscripcion)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_Duracion_de_Planes_de_SuscripcionGenerateID", new JavaScriptSerializer().Serialize(varDuracion_de_Planes_de_Suscripcion), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_Duracion_de_Planes_de_SuscripcionGenerateID", new JavaScriptSerializer().Serialize(varDuracion_de_Planes_de_Suscripcion), true); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter)); }