public HttpResponseMessage Post(Semanas_Planes varSemanas_Planes) { if (ModelState.IsValid) { var data = "-1"; try { data = Convert.ToString(this.service.Insert(varSemanas_Planes)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsSemanas_Planes", new JavaScriptSerializer().Serialize(varSemanas_Planes), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsSemanas_Planes", new JavaScriptSerializer().Serialize(varSemanas_Planes), 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_InsSemanas_Planes", new JavaScriptSerializer().Serialize(varSemanas_Planes), false, errors.ToString()); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.BadRequest, errors)); } }
public HttpResponseMessage Delete(int id) { Semanas_Planes varSemanas_Planes = this.service.GetByKey(id, false); bool result = false; if (varSemanas_Planes == 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_DelSemanas_Planes", new JavaScriptSerializer().Serialize(varSemanas_Planes), result); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelSemanas_Planes", new JavaScriptSerializer().Serialize(varSemanas_Planes), 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) { Semanas_Planes entity = this.service.ListaSelAll(1, 1, "Semanas_Planes.Folio='" + id.ToString() + "'", "").Semanas_Planess.First(); Semanas_Planes result = new Semanas_Planes(); result.Folio = entity.Folio; result.Semana = entity.Semana; result.Semanas_del_mes = entity.Semanas_del_mes; return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter)); }
public HttpResponseMessage PutTunnel(Semanas_Planes 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(Semanas_Planes varSemanas_Planes_Datos_Generales) { var data = "-1"; try { data = Convert.ToString(this.service.Update_Datos_Generales(varSemanas_Planes_Datos_Generales)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varSemanas_Planes_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdSemanas_Planes", new JavaScriptSerializer().Serialize(varSemanas_Planes_Datos_Generales), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varSemanas_Planes_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdSemanas_Planes", new JavaScriptSerializer().Serialize(varSemanas_Planes_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 Semanas_PlanesGenerateID() { Semanas_Planes varSemanas_Planes = new Semanas_Planes(); var data = "-1"; try { data = Convert.ToString(this.service.Insert(varSemanas_Planes)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_Semanas_PlanesGenerateID", new JavaScriptSerializer().Serialize(varSemanas_Planes), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_Semanas_PlanesGenerateID", new JavaScriptSerializer().Serialize(varSemanas_Planes), true); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter)); }