Esempio n. 1
0
        public ActionResult AjaxVideoQuery(VideoResourceQuery query)
        {
            query.OwnerID = OwnerID;
            var targetList = Service.Select(query);

            ViewData["Pagination"] = Pagination.FromQuery(query);
            return(PartialView("Resource/VideoList", targetList.ToList()));
        }
Esempio n. 2
0
        public ActionResult Video()
        {
            var query = new VideoResourceQuery()
            {
                OwnerID        = OwnerID,
                Take           = PageSize,
                OrderField     = "LastModifiedAt",
                OrderDirection = OrderDirection.Desc,
            };
            var video = Service.Select(query).ToList();

            ViewData["Pagination"] = Pagination.FromQuery(query);
            ViewData["Query"]      = query;
            return(View(video));
        }
        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));
        }