public HttpResponseMessage Post(Detalle_de_Ingredientes varDetalle_de_Ingredientes) { if (ModelState.IsValid) { var data = "-1"; try { data = Convert.ToString(this.service.Insert(varDetalle_de_Ingredientes)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsDetalle_de_Ingredientes", new JavaScriptSerializer().Serialize(varDetalle_de_Ingredientes), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsDetalle_de_Ingredientes", new JavaScriptSerializer().Serialize(varDetalle_de_Ingredientes), 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_InsDetalle_de_Ingredientes", new JavaScriptSerializer().Serialize(varDetalle_de_Ingredientes), false, errors.ToString()); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.BadRequest, errors)); } }
public HttpResponseMessage Delete(int id) { Detalle_de_Ingredientes varDetalle_de_Ingredientes = this.service.GetByKey(id, false); bool result = false; if (varDetalle_de_Ingredientes == 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_DelDetalle_de_Ingredientes", new JavaScriptSerializer().Serialize(varDetalle_de_Ingredientes), result); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelDetalle_de_Ingredientes", new JavaScriptSerializer().Serialize(varDetalle_de_Ingredientes), result, ex.Message); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public HttpResponseMessage PutTunnel(Detalle_de_Ingredientes 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 Get_Datos_Generales(int id) { Detalle_de_Ingredientes entity = this.service.ListaSelAll(1, 1, "Detalle_de_Ingredientes.Clave='" + id.ToString() + "'", "").Detalle_de_Ingredientess.First(); Detalle_de_Ingredientes result = new Detalle_de_Ingredientes(); result.Clave = entity.Clave; result.Cantidad = entity.Cantidad; result.Unidad = entity.Unidad; result.Unidad_Unidades_de_Medida = entity.Unidad_Unidades_de_Medida; result.Nombre_del_Ingrediente = entity.Nombre_del_Ingrediente; result.Nombre_del_Ingrediente_Ingredientes = entity.Nombre_del_Ingrediente_Ingredientes; result.Nombre_de_presentacion = entity.Nombre_de_presentacion; result.Nombre_de_presentacion_Presentacion = entity.Nombre_de_presentacion_Presentacion; result.Nombre_de_Marca = entity.Nombre_de_Marca; result.Nombre_de_Marca_Marca = entity.Nombre_de_Marca_Marca; return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter)); }
public HttpResponseMessage Put_Datos_Generales(Detalle_de_Ingredientes varDetalle_de_Ingredientes_Datos_Generales) { var data = "-1"; try { data = Convert.ToString(this.service.Update_Datos_Generales(varDetalle_de_Ingredientes_Datos_Generales)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varDetalle_de_Ingredientes_Datos_Generales.Clave, BitacoraHelper.TypeSql.UPDATE, "sp_UpdDetalle_de_Ingredientes", new JavaScriptSerializer().Serialize(varDetalle_de_Ingredientes_Datos_Generales), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varDetalle_de_Ingredientes_Datos_Generales.Clave, BitacoraHelper.TypeSql.UPDATE, "sp_UpdDetalle_de_Ingredientes", new JavaScriptSerializer().Serialize(varDetalle_de_Ingredientes_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 Detalle_de_IngredientesGenerateID() { Detalle_de_Ingredientes varDetalle_de_Ingredientes = new Detalle_de_Ingredientes(); var data = "-1"; try { data = Convert.ToString(this.service.Insert(varDetalle_de_Ingredientes)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_Detalle_de_IngredientesGenerateID", new JavaScriptSerializer().Serialize(varDetalle_de_Ingredientes), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_Detalle_de_IngredientesGenerateID", new JavaScriptSerializer().Serialize(varDetalle_de_Ingredientes), true); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter)); }
public ActionResult Post(bool IsNew, Detalle_de_IngredientesModel varDetalle_de_Ingredientes) { try { if (ModelState.IsValid) { if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IDetalle_de_IngredientesApiConsumer.SetAuthHeader(_tokenManager.Token); var result = ""; var Detalle_de_IngredientesInfo = new Detalle_de_Ingredientes { Clave = varDetalle_de_Ingredientes.Clave , Cantidad = varDetalle_de_Ingredientes.Cantidad , Unidad = varDetalle_de_Ingredientes.Unidad , Nombre_del_Ingrediente = varDetalle_de_Ingredientes.Nombre_del_Ingrediente , Nombre_de_presentacion = varDetalle_de_Ingredientes.Nombre_de_presentacion , Nombre_de_Marca = varDetalle_de_Ingredientes.Nombre_de_Marca }; result = !IsNew? _IDetalle_de_IngredientesApiConsumer.Update(Detalle_de_IngredientesInfo, null, null).Resource.ToString() : _IDetalle_de_IngredientesApiConsumer.Insert(Detalle_de_IngredientesInfo, null, null).Resource.ToString(); return(Json(result, JsonRequestBehavior.AllowGet)); } return(Json(false, JsonRequestBehavior.AllowGet)); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }
public ActionResult Delete(int id) { try { if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IDetalle_de_IngredientesApiConsumer.SetAuthHeader(_tokenManager.Token); Detalle_de_Ingredientes varDetalle_de_Ingredientes = null; if (id.ToString() != "0") { string where = ""; } var result = _IDetalle_de_IngredientesApiConsumer.Delete(id, null, null).Resource; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }