public ActionResult GetServices() { var allAnunciosList = new List<AN_Anuncios>(); List<AnunciosViewModel> viewModelAnuncios = new List<AnunciosViewModel>(); using (Entities model = new Entities()) { allAnunciosList = model.AN_Anuncios.AsParallel().OrderByDescending(c => c.AN_Fecha).Where(sts => sts.ST_Id == 1).ToList(); foreach (var item in allAnunciosList) { string username = item.UserProfile.Name; string statusDesc = item.ST_Estatus.ST_Descripcion; var categoria = item.SBS_SubCategoriaServicio.CD_CategoriaServicio.CD_Descripcion; var firstImage = string.Empty; if (item.AE_AnunciosExtras.FirstOrDefault() != null) { firstImage = item.AE_AnunciosExtras.FirstOrDefault().AN_ImagenUrl; } else { firstImage = item.UserProfile.Image == null ? "~/Images/No_Profile.jpg" : item.UserProfile.Image; } //item.AN_Fecha = Convert.ToDateTime(item.AN_Fecha.ToShortDateString()); var getRating = model.SEL_ValoracionAnuncios(item.AN_Id).FirstOrDefault(); string urlimg = Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/"); var formatted = firstImage.Replace("~", ""); if (formatted.StartsWith("/")) formatted = formatted.Remove(0, 1); firstImage = urlimg + formatted; var number = 0; item.SS_SolicitudServicio.AsParallel().ToList().ForEach((counter) => { number += counter.RW_Reviews.Count; }); viewModelAnuncios.Add(new AnunciosViewModel { Usuario = username, EstatusDescription = statusDesc, AnunciosInfo = item, CategoriaDescripcion = categoria, FirstImage = firstImage, Rating = getRating, Comments = number, }); } } if (viewModelAnuncios == null || viewModelAnuncios.Count == 0) { return HttpNotFound(); } var anuncios = viewModelAnuncios.SerializeToJson(); return Json(anuncios); }
public ActionResult GetProductsBanners() { try { var productos = new List<PRO_Productos>(); productos = db.PRO_Productos.Where(c => c.PRO_IsBanner == true).ToList(); if (productos == null) { return HttpNotFound(); } else { string productlist = productos.SerializeToJson(); return Json(productlist); } } catch (Exception ex) { throw ex; } }
public ActionResult GetInfoPage() { try { var detalle = new List<PRC_PantallaInicial>(); detalle = db.PRC_PantallaInicial.Where(c => c.STS_Id == 1).ToList(); if (detalle == null) { return HttpNotFound(); } else { string detallelist = detalle.SerializeToJson(); return Json(detallelist); } } catch (Exception ex) { throw ex; } }
public ActionResult GetInformationAnuncios(FormCollection form) { var allAnunciosList = new List<AN_Anuncios>(); var category = string.IsNullOrEmpty(form["Categoria"]) ? default(int) : int.Parse(form["Categoria"].ToString()); var subcategoria = string.IsNullOrEmpty(form["SubCategoria"]) ? default(int) : int.Parse(form["SubCategoria"].ToString()); var lugar = string.IsNullOrEmpty(form["Lugar"]) ? default(string) : form["Lugar"].ToString(); var descripcion = string.IsNullOrEmpty(form["Descripcion"]) ? default(string) : form["Descripcion"].ToString(); List<AnunciosViewModel> viewModelAnuncios = new List<AnunciosViewModel>(); using (Entities model = new Entities()) { allAnunciosList = db.Get_AdvanceSearch(category, subcategoria, descripcion, lugar).ToList(); foreach (var item in allAnunciosList) { string username = item.UserProfile.Name; string statusDesc = item.ST_Estatus.ST_Descripcion; var categoria = item.SBS_SubCategoriaServicio.CD_CategoriaServicio.CD_Descripcion; var firstImage = string.Empty; if (item.AE_AnunciosExtras.FirstOrDefault() != null) { firstImage = item.AE_AnunciosExtras.FirstOrDefault().AN_ImagenUrl; } else { firstImage = item.UserProfile.Image == null ? "~/Images/No_Profile.jpg" : item.UserProfile.Image; } var getRating = model.SEL_ValoracionAnuncios(item.AN_Id).FirstOrDefault(); string urlimg = Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/"); var formatted = firstImage.Replace("~", ""); if (formatted.StartsWith("/")) formatted = formatted.Remove(0, 1); firstImage = urlimg + formatted; List<RW_Reviews> rvList = new List<RW_Reviews>(); model.SS_SolicitudServicio.Where(c => c.AN_Id == item.AN_Id).AsParallel().ToList().ForEach( c => { c.RW_Reviews.AsParallel().ToList().ForEach(i => rvList.Add(i)); }); viewModelAnuncios.Add(new AnunciosViewModel { Usuario = username, EstatusDescription = statusDesc, AnunciosInfo = item, CategoriaDescripcion = categoria, FirstImage = firstImage, Rating = getRating, ReviewList = rvList }); } } if (viewModelAnuncios == null || viewModelAnuncios.Count == 0) { return Json(new { Error = "No se encontraron registros" }); } var anuncios = viewModelAnuncios.SerializeToJson(); return Json(anuncios); }
private void WriteJsonIframeSafe(HttpContext context, List<FilesStatus> statuses) { context.Response.AddHeader("Vary", "Accept"); try { if (context.Request["HTTP_ACCEPT"].Contains("application/json")) context.Response.ContentType = "application/json"; else context.Response.ContentType = "text/plain"; } catch { context.Response.ContentType = "text/plain"; } var jsonObj = statuses.SerializeToJson(); context.Response.Write(jsonObj); }
public ActionResult GetNewTop3() { var news = new List<NEW_Noticias>(); news = db.NEW_Noticias.Where(c => c.STS_Id == 1).OrderByDescending(d => d.NEW_Date).Take(3).ToList(); if (news == null) { return HttpNotFound(); } else { string newslist = news.SerializeToJson(); return Json(newslist); } }
public ActionResult GetProductsDetails(int prod) { var productos = new List<PRD_ProductosDetalles>(); productos = db.PRD_ProductosDetalles.Where(c => c.PRO_Id == prod ).ToList(); if (productos == null) { return HttpNotFound(); } else { string productlist = productos.SerializeToJson(); return Json(productlist); } }
public ActionResult GetProductsByCategory(int catid) { var productos = new List<PRO_Productos>(); productos = db.PRO_Productos.Where(c => c.CAT_Id == catid && c.STS_Id==1).ToList(); if (productos == null) { return HttpNotFound(); } else { string productlist = productos.SerializeToJson(); return Json(productlist); } }
public ActionResult GetProductsTop(int counter) { var productos = new List<PRO_Productos>(); productos = db.PRO_Productos.Where(c => c.STS_Id == 1).OrderByDescending(d => d.PRO_Date).Take(counter).ToList(); if (productos == null) { return HttpNotFound(); } else { string productlist = productos.SerializeToJson(); return Json(productlist); } }