public string Crear(DataServicio Data) { string authHeader = WebOperationContext.Current.IncomingRequest.Headers["Authorization"]; if (HToken.check(authHeader)) { if (Data.Id != 0) { CustomErrorDetail customError = new CustomErrorDetail(400, "Error en la peticion", "La peticion no tiene el formato requerido"); throw new WebFaultException <CustomErrorDetail>(customError, HttpStatusCode.BadRequest); } return(JsonConvert.SerializeObject(new { Respuesta = _sv.CrearServicio(Data) })); } WebOperationContext.Current.OutgoingResponse.Headers.Add("WWW-Authorization: Token realm=\"wscreate\""); throw new WebFaultException(HttpStatusCode.Unauthorized); }
public string Actualizar(DataServicio Data) { string authHeader = WebOperationContext.Current.IncomingRequest.Headers["Authorization"]; if (HToken.check(authHeader)) { if (Data.Id == 0) { CustomErrorDetail customError = new CustomErrorDetail(404, "Dato Faltante", "El identificador no se encontro"); throw new WebFaultException <CustomErrorDetail>(customError, HttpStatusCode.NotFound); } return(JsonConvert.SerializeObject(new { Respuesta = _sv.ActualizarServicio(Data) })); } WebOperationContext.Current.OutgoingResponse.Headers.Add("WWW-Authorization: Token realm=\"wsupdate\""); throw new WebFaultException(HttpStatusCode.Unauthorized); }
public string UploadImg(UploadImgB File) { string authHeader = WebOperationContext.Current.IncomingRequest.Headers["Authorization"]; if (HToken.check(authHeader)) { if (string.IsNullOrEmpty(File.Nombre) && string.IsNullOrEmpty(File.Imagen)) { CustomErrorDetail customError = new CustomErrorDetail(404, "Dato Faltante", "El nombre y la imagen son obligatorios"); throw new WebFaultException <CustomErrorDetail>(customError, HttpStatusCode.NotFound); } HUploadImgeBit.ImagesSys(File.Imagen, File.Nombre, "/Recursos/"); return(JsonConvert.SerializeObject(new { Respuesta = _me.UploadImgBit(File) })); } WebOperationContext.Current.OutgoingResponse.Headers.Add("WWW-Authorization: Token realm=\"wsuploadbit\""); throw new WebFaultException(HttpStatusCode.Unauthorized); }
public string MostrarRegistro(string Id) { string authHeader = WebOperationContext.Current.IncomingRequest.Headers["Authorization"]; int valorId = Convert.ToInt32(Id); if (HToken.check(authHeader)) { if (!string.IsNullOrEmpty(Id)) { CustomErrorDetail customError = new CustomErrorDetail(404, "Dato Faltante", "El identificador no se encontro"); throw new WebFaultException <CustomErrorDetail>(customError, HttpStatusCode.NotFound); } return(JsonConvert.SerializeObject(new { Respuesta = _sv.MuestraServicio(valorId) })); } WebOperationContext.Current.OutgoingResponse.Headers.Add("WWW-Authorization: Token realm=\"wsread\""); throw new WebFaultException(HttpStatusCode.Unauthorized); }