public HttpResponseMessage Post(areas_Empresas varareas_Empresas) { if (ModelState.IsValid) { var data = "-1"; try { data = Convert.ToString(this.service.Insert(varareas_Empresas)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_Insareas_Empresas", new JavaScriptSerializer().Serialize(varareas_Empresas), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_Insareas_Empresas", new JavaScriptSerializer().Serialize(varareas_Empresas), 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_Insareas_Empresas", new JavaScriptSerializer().Serialize(varareas_Empresas), false, errors.ToString()); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.BadRequest, errors)); } }
public HttpResponseMessage Delete(int id) { areas_Empresas varareas_Empresas = this.service.GetByKey(id, false); bool result = false; if (varareas_Empresas == 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_Delareas_Empresas", new JavaScriptSerializer().Serialize(varareas_Empresas), result); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_Delareas_Empresas", new JavaScriptSerializer().Serialize(varareas_Empresas), result, ex.Message); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public ActionResult Post(bool IsNew, areas_EmpresasModel varareas_Empresas) { try { //if (ModelState.IsValid) //{ if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _Iareas_EmpresasApiConsumer.SetAuthHeader(_tokenManager.Token); var result = ""; var areas_EmpresasInfo = new areas_Empresas { Clave = varareas_Empresas.Clave , Nombre = varareas_Empresas.Nombre }; result = !IsNew? _Iareas_EmpresasApiConsumer.Update(areas_EmpresasInfo, null, null).Resource.ToString() : _Iareas_EmpresasApiConsumer.Insert(areas_EmpresasInfo, 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) { areas_Empresas entity = this.service.ListaSelAll(1, 1, "areas_Empresas.Clave='" + id.ToString() + "'", "").areas_Empresass.First(); areas_Empresas result = new areas_Empresas(); result.Clave = entity.Clave; result.Nombre = entity.Nombre; return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter)); }
public HttpResponseMessage PutTunnel(areas_Empresas 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(areas_Empresas varareas_Empresas_Datos_Generales) { var data = "-1"; try { data = Convert.ToString(this.service.Update_Datos_Generales(varareas_Empresas_Datos_Generales)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varareas_Empresas_Datos_Generales.Clave, BitacoraHelper.TypeSql.UPDATE, "sp_Updareas_Empresas", new JavaScriptSerializer().Serialize(varareas_Empresas_Datos_Generales), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varareas_Empresas_Datos_Generales.Clave, BitacoraHelper.TypeSql.UPDATE, "sp_Updareas_Empresas", new JavaScriptSerializer().Serialize(varareas_Empresas_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 areas_EmpresasGenerateID() { areas_Empresas varareas_Empresas = new areas_Empresas(); var data = "-1"; try { data = Convert.ToString(this.service.Insert(varareas_Empresas)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_areas_EmpresasGenerateID", new JavaScriptSerializer().Serialize(varareas_Empresas), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_areas_EmpresasGenerateID", new JavaScriptSerializer().Serialize(varareas_Empresas), 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)); } _Iareas_EmpresasApiConsumer.SetAuthHeader(_tokenManager.Token); areas_Empresas varareas_Empresas = null; if (id.ToString() != "0") { string where = ""; } var result = _Iareas_EmpresasApiConsumer.Delete(id, null, null).Resource; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }