public ActionResult AjaxPicQuery(PictureResourceQuery query) { query.OwnerID = OwnerID; var targetList = Service.Select(query); ViewData["Pagination"] = Pagination.FromQuery(query); return(PartialView("Resource/PictureList", targetList.ToList())); }
public ActionResult Picture() { var query = new PictureResourceQuery() { OwnerID = OwnerID, Take = PageSize, OrderField = "LastModifiedAt", OrderDirection = OrderDirection.Desc, }; var pics = Service.Select(query).ToList(); foreach (var pic in pics) { pic.Name = GetName(pic, ItemSize); } ViewData["Pagination"] = Pagination.FromQuery(query); ViewData["Query"] = query; return(View(pics)); }
public ActionResult GetResource(int type, int page) { var svc = Service; if (!Enum.IsDefined(typeof(ResourceType), type)) { return(Json(new { success = false, msg = "" }, JsonRequestBehavior.AllowGet)); } int perPage = 10; if (page <= 0) { page = 1; } var skip = (page - 1) * perPage; var take = 10; long count = 0; ViewData["Type"] = type; IEnumerable <Resource> resources = null; string ftp; switch (type) { case (int)ResourceType.Audio: var q = new AudioResourceQuery() { OwnerID = OwnerID, Take = take, Skip = skip }; resources = svc.Select(q); count = q.Count.Value; ftp = ConfigurationManager.AppSettings["ftp"]; foreach (var r in resources) { var t = r as FileResource; t.Path = Path.Combine(ftp, t.Path, t.Name); } break; case (int)ResourceType.News: var q2 = new NewsResourceQuery() { OwnerID = OwnerID, Take = take, Skip = skip }; resources = svc.Select(q2); count = q2.Count.Value; break; case (int)ResourceType.Picture: var q3 = new PictureResourceQuery() { OwnerID = OwnerID, Take = take, Skip = skip }; resources = svc.Select(q3); ftp = ConfigurationManager.AppSettings["ftp"]; foreach (var r in resources) { var t = r as FileResource; t.Path = Path.Combine(ftp, t.Path, t.Name); } count = q3.Count.Value; break; case (int)ResourceType.Video: var q4 = new VideoResourceQuery() { OwnerID = OwnerID, Take = take, Skip = skip }; resources = svc.Select(q4); ftp = ConfigurationManager.AppSettings["ftp"]; foreach (var r in resources) { var t = r as FileResource; t.Path = Path.Combine(ftp, t.Path, t.Name); } count = q4.Count.Value; break; } return(Json(new { page = page, rows = resources, total = count }, JsonRequestBehavior.AllowGet)); }