public HttpResponseMessage Post(Rango_de_Horas varRango_de_Horas) { if (ModelState.IsValid) { var data = "-1"; try { data = Convert.ToString(this.service.Insert(varRango_de_Horas)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsRango_de_Horas", new JavaScriptSerializer().Serialize(varRango_de_Horas), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsRango_de_Horas", new JavaScriptSerializer().Serialize(varRango_de_Horas), 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_InsRango_de_Horas", new JavaScriptSerializer().Serialize(varRango_de_Horas), false, errors.ToString()); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.BadRequest, errors)); } }
public HttpResponseMessage Delete(int id) { Rango_de_Horas varRango_de_Horas = this.service.GetByKey(id, false); bool result = false; if (varRango_de_Horas == 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_DelRango_de_Horas", new JavaScriptSerializer().Serialize(varRango_de_Horas), result); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelRango_de_Horas", new JavaScriptSerializer().Serialize(varRango_de_Horas), 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) { Rango_de_Horas entity = this.service.ListaSelAll(1, 1, "Rango_de_Horas.Clave='" + id.ToString() + "'", "").Rango_de_Horass.First(); Rango_de_Horas result = new Rango_de_Horas(); result.Clave = entity.Clave; result.Descripcion = entity.Descripcion; return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter)); }
public HttpResponseMessage PutTunnel(Rango_de_Horas 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(Rango_de_Horas varRango_de_Horas_Datos_Generales) { var data = "-1"; try { data = Convert.ToString(this.service.Update_Datos_Generales(varRango_de_Horas_Datos_Generales)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varRango_de_Horas_Datos_Generales.Clave, BitacoraHelper.TypeSql.UPDATE, "sp_UpdRango_de_Horas", new JavaScriptSerializer().Serialize(varRango_de_Horas_Datos_Generales), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varRango_de_Horas_Datos_Generales.Clave, BitacoraHelper.TypeSql.UPDATE, "sp_UpdRango_de_Horas", new JavaScriptSerializer().Serialize(varRango_de_Horas_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 Rango_de_HorasGenerateID() { Rango_de_Horas varRango_de_Horas = new Rango_de_Horas(); var data = "-1"; try { data = Convert.ToString(this.service.Insert(varRango_de_Horas)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_Rango_de_HorasGenerateID", new JavaScriptSerializer().Serialize(varRango_de_Horas), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_Rango_de_HorasGenerateID", new JavaScriptSerializer().Serialize(varRango_de_Horas), 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)); } _IRango_de_HorasApiConsumer.SetAuthHeader(_tokenManager.Token); Rango_de_Horas varRango_de_Horas = null; if (id.ToString() != "0") { string where = ""; } var result = _IRango_de_HorasApiConsumer.Delete(id, null, null).Resource; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }