Пример #1
0
        protected override DriverResult Display(AdvertiseHomePart part, string displayType, dynamic shapeHelper)
        {
            int cultureId = CurrentContent.As <LocalizationPart>().Culture.Id;

            IEnumerable <AdvertisePart> parts = _advertiseService.Get(VersionOptions.Latest, cultureId);

            return(ContentShape("Parts_AdvertiseHome", () => {
                return shapeHelper.Parts_AdvertiseHome(
                    AdvertiseParts: parts);
            }));
        }
Пример #2
0
        public ActionResult Item(int advertiseId, PagerParameters pagerParameters)
        {
            Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);

            var advertisePart = _advertiseService.Get(advertiseId, VersionOptions.Published).As <AdvertisePart>();

            if (advertisePart == null)
            {
                return(HttpNotFound());
            }

            if (!_services.Authorizer.Authorize(Orchard.Core.Contents.Permissions.ViewContent, advertisePart, T("Cannot view content")))
            {
                return(new HttpUnauthorizedResult());
            }

            dynamic advertise = _services.ContentManager.BuildDisplay(advertisePart);

            return(new ShapeResult(this, advertise));
        }
Пример #3
0
        private void BuildMenu(NavigationItemBuilder menu)
        {
            var advertises      = _advertiseService.Get().Where(x => _authorizationService.TryCheckAccess(Permissions.ManageAdvertise, _workContextAccessor.GetContext().CurrentUser, x)).ToArray();
            var advertiseCount  = advertises.Count();
            var singleAdvertise = advertiseCount == 1 ? advertises.ElementAt(0) : null;

            if (advertiseCount > 0 && singleAdvertise == null)
            {
                menu.Add(T("Manage Advertises"), "3",
                         item => item.Action("List", "AdvertiseAdmin", new { area = "Orchard.Advertise" }).Permission(Permissions.ManageAdvertise));
            }
            else if (singleAdvertise != null)
            {
                menu.Add(T("Manage Advertise"), "1.0",
                         item => item.Action("Item", "AdvertiseAdmin", new { area = "Orchard.Advertise", advertiseId = singleAdvertise.Id }).Permission(Permissions.ManageOwnAdvertise));
            }

            menu.Add(T("New Advertise"), "1.2",
                     item =>
                     item.Action("Create", "AdvertiseAdmin", new { area = "Orchard.Advertise" }).Permission(Permissions.ManageAdvertise));
        }
Пример #4
0
        public ActionResult Edit(int advertiseId)
        {
            var advertise = _advertiseService.Get(advertiseId, VersionOptions.Latest);

            if (!Services.Authorizer.Authorize(Permissions.ManageAdvertise, advertise, T("Not allowed to edit advertise")))
            {
                return(new HttpUnauthorizedResult());
            }

            if (advertise == null)
            {
                return(HttpNotFound());
            }

            var model = Services.ContentManager.BuildEditor(advertise);

            return(View(model));
        }