public HttpResponseMessage Get() { var Session = HttpContext.Current.Session; HttpResponseMessage msg = new HttpResponseMessage(); if (Session["UserNit"] != null) { string Nit = Session["UserNit"].ToString(); int id; int page; string RefId = string.Empty; List <Referencia> referencias; if (HttpContext.Current.Request.QueryString["oferta"] != null && HttpContext.Current.Request.QueryString["oferta"].ToString() != "undefined") { id = System.Convert.ToInt32(HttpContext.Current.Request.QueryString["oferta"]); page = System.Convert.ToInt32(HttpContext.Current.Request.QueryString["page"]); ReferenciaService rs = new ReferenciaService(); referencias = rs.GetReferenciasByOferta(Nit, id, System.Convert.ToInt32(page), true, false); HttpContext.Current.Response.AppendHeader("pages", rs.GetPagesLastQuery().ToString()); msg = new HttpResponseMessage(); msg.Content = new ObjectContent <object>(referencias, new System.Net.Http.Formatting.JsonMediaTypeFormatter()); msg.StatusCode = HttpStatusCode.OK; return(msg); } if (HttpContext.Current.Request.QueryString["refid"] != null) { RefId = HttpContext.Current.Request.QueryString["refid"].ToString(); if (RefId != null && RefId != string.Empty) { ReferenciaService rs = new ReferenciaService(); referencias = new List <Referencia>(); referencias.Add(rs.GetReferencia(Nit, RefId, true, false)); msg = new HttpResponseMessage(); msg.Content = new ObjectContent <object>(referencias, new System.Net.Http.Formatting.JsonMediaTypeFormatter()); msg.StatusCode = HttpStatusCode.OK; return(msg); } } msg = new HttpResponseMessage(); msg.Content = new ObjectContent <object>("No hay referencias disponibles", new System.Net.Http.Formatting.JsonMediaTypeFormatter()); msg.StatusCode = HttpStatusCode.OK; return(msg); } else { msg.Content = new ObjectContent <object>("La sesiĆ³n ha sido finalizada por inactividad", new System.Net.Http.Formatting.JsonMediaTypeFormatter()); msg.StatusCode = HttpStatusCode.Gone; return(msg); } }
public HttpResponseMessage Get() { var Session = HttpContext.Current.Session; int OfertaId = System.Convert.ToInt32(HttpContext.Current.Request.QueryString["oferta"]); string ReferenciaId = HttpContext.Current.Request.QueryString["refid"].ToString(); Boolean loadImages = System.Convert.ToBoolean(HttpContext.Current.Request.QueryString["loadImages"]); ReferenciaService rs = new ReferenciaService(); var referencia = rs.GetReferencia(OfertaId, ReferenciaId, true); HttpResponseMessage msg = new HttpResponseMessage(); msg.Content = new ObjectContent <object>(referencia, new System.Net.Http.Formatting.JsonMediaTypeFormatter()); msg.StatusCode = HttpStatusCode.OK; return(msg); }