Exemplo n.º 1
0
        public virtual ActionResult MultipleSelector(int page = 1, string parentpath = null, Guid?parentid = null)
        {
            if (!User.Identity.IsAuthenticated && !Metadata.AllowAnonymous)
            {
                return(new HttpStatusCodeResult(403));
            }
            if (!Metadata.ViewRoles.All(t => User.IsInRole(t)))
            {
                return(new HttpStatusCodeResult(403));
            }
            IQueryable <TEntity> queryable = EntityQueryable.Query();

            if (parentpath != null && parentid.HasValue)
            {
                try
                {
                    queryable = EntityQueryable.InParent(queryable, parentpath, parentid.Value);
                }
                catch
                {
                    return(new HttpStatusCodeResult(400));
                }
            }
            var model = new EntityViewModel <TEntity>(EntityQueryable.OrderBy(queryable), page, 10);

            if (Metadata.ParentProperty != null)
            {
                model.Parent = GetParentModel(parentid, 3);
            }
            model.Headers = Metadata.ViewProperties;
            model.UpdateItems();
            return(View(model));
        }