public HttpResponseMessage Post(Nivel_de_Intensidad varNivel_de_Intensidad) { if (ModelState.IsValid) { var data = "-1"; try { data = Convert.ToString(this.service.Insert(varNivel_de_Intensidad)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsNivel_de_Intensidad", new JavaScriptSerializer().Serialize(varNivel_de_Intensidad), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsNivel_de_Intensidad", new JavaScriptSerializer().Serialize(varNivel_de_Intensidad), 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_InsNivel_de_Intensidad", new JavaScriptSerializer().Serialize(varNivel_de_Intensidad), false, errors.ToString()); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.BadRequest, errors)); } }
public HttpResponseMessage Delete(int id) { Nivel_de_Intensidad varNivel_de_Intensidad = this.service.GetByKey(id, false); bool result = false; if (varNivel_de_Intensidad == 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_DelNivel_de_Intensidad", new JavaScriptSerializer().Serialize(varNivel_de_Intensidad), result); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelNivel_de_Intensidad", new JavaScriptSerializer().Serialize(varNivel_de_Intensidad), 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) { Nivel_de_Intensidad entity = this.service.ListaSelAll(1, 1, "Nivel_de_Intensidad.Folio='" + id.ToString() + "'", "").Nivel_de_Intensidads.First(); Nivel_de_Intensidad result = new Nivel_de_Intensidad(); result.Folio = entity.Folio; result.Intensidad = entity.Intensidad; return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter)); }
public HttpResponseMessage PutTunnel(Nivel_de_Intensidad 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.Folio), "PUT" , dataString); return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter)); }
public HttpResponseMessage Put_Datos_Generales(Nivel_de_Intensidad varNivel_de_Intensidad_Datos_Generales) { var data = "-1"; try { data = Convert.ToString(this.service.Update_Datos_Generales(varNivel_de_Intensidad_Datos_Generales)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varNivel_de_Intensidad_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdNivel_de_Intensidad", new JavaScriptSerializer().Serialize(varNivel_de_Intensidad_Datos_Generales), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varNivel_de_Intensidad_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdNivel_de_Intensidad", new JavaScriptSerializer().Serialize(varNivel_de_Intensidad_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 Nivel_de_IntensidadGenerateID() { Nivel_de_Intensidad varNivel_de_Intensidad = new Nivel_de_Intensidad(); var data = "-1"; try { data = Convert.ToString(this.service.Insert(varNivel_de_Intensidad)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_Nivel_de_IntensidadGenerateID", new JavaScriptSerializer().Serialize(varNivel_de_Intensidad), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_Nivel_de_IntensidadGenerateID", new JavaScriptSerializer().Serialize(varNivel_de_Intensidad), true); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter)); }