public async Task<IViewComponentResult> InvokeAsync(
            int? categoryId = null,
            string viewName = "") {

            var model = new WebsiteFooterViewModel();

            if (categoryId.HasValue) {

            }
            else {

            }

            model.Subscriber = new SubscriberViewModel();

            var socialNetworks = await _websiteOptionService
                .GetSocialNetworksAsync();

            if (socialNetworks != null)
                model.SocialNetworks = socialNetworks
                    .Adapt<WebsiteSocialNetworksViewModel>();

            var contactInfo = await _websiteOptionService.GetContactInfoAsync();
            if (contactInfo != null)
                model.ContactInfo = contactInfo.Adapt<WebsiteContactInfoViewModel>();

            if (viewName.IsNotNullOrEmpty())
                return await Task.FromResult(
                    View(viewName, model)
                    );

            return await Task.FromResult(
                View(model)
                );
        }
Esempio n. 2
0
        public async Task <IViewComponentResult> InvokeAsync(
            string postType,
            string aboutText,
            string aboutUrl,
            string lang     = "fa",
            int pageSize    = 5,
            string viewName = "")
        {
            var model = new WebsiteFooterViewModel();

            var posts = await _postService.GetLatestPostsAsync(
                postType, null, lang, pageSize);

            if (posts != null && posts.Items.Any())
            {
                model.Posts = posts.Items.Adapt <List <PostItemViewModel> >();
            }

            model.Subscriber = new SubscriberViewModel();

            var contactInfo = await _websiteOptionService.GetContactInfoAsync(lang);

            //var contactInfo = _websiteOptionService.GetContactInfo(lang);
            if (contactInfo != null)
            {
                model.ContactInfo = contactInfo.Adapt <WebsiteContactInfoViewModel>();
            }

            var copyrightText = await _websiteOptionService.GetOptionAsync("Copyright", lang);

            if (copyrightText != null)
            {
                model.CopyrightText = copyrightText.Value;
            }

            var socialNetworks = await _websiteOptionService
                                 .GetSocialNetworksAsync();

            if (socialNetworks != null)
            {
                model.SocialNetworks = socialNetworks.Adapt <WebsiteSocialNetworksViewModel>();
            }

            model.AboutText = aboutText;
            model.AboutUrl  = aboutUrl;

            if (viewName.IsNotNullOrEmpty())
            {
                return(await Task.FromResult(
                           View(viewName, model)
                           ));
            }

            return(await Task.FromResult(
                       View(model)
                       ));
        }