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) )); }
private async Task <WebsiteOptionViewModel> getOptionAsync(string optionKey) { try { var option = await _websiteOptionService.GetOptionAsync(optionKey); return(option.Adapt <WebsiteOptionViewModel>()); } catch { return(null); } }