FooterViewComponent.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using CZFW.Framework.Interface;
  2. using CZFW.Framework.Model;
  3. using CZFW.Framework.Model.Entity;
  4. using CZKJ.GBRS2.WebMVC.Models;
  5. using Microsoft.AspNetCore.Mvc;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Threading.Tasks;
  10. namespace CZKJ.GBRS2.WebMVC.ViewComponents
  11. {
  12. public class FooterViewComponent : ViewComponent
  13. {
  14. public IViewComponentResult Invoke()
  15. {
  16. var item = GetItems();
  17. return View(item);
  18. }
  19. private FooterModel GetItems()
  20. {
  21. ISysConfig sys = CZHttpContext.ServiceProvider.GetService(typeof(ISysConfig)) as ISysConfig;
  22. INavigation na = CZHttpContext.ServiceProvider.GetService(typeof(INavigation)) as INavigation;
  23. ILink link = CZHttpContext.ServiceProvider.GetService(typeof(ILink)) as ILink;
  24. var result = sys.GetSysConfig("Phone", "ZipCode", "Address", "WeChatCode", "MicroBlog", "Record");
  25. var model = new FooterModel();
  26. model.Phone = result.FirstOrDefault(x => x.Key == "Phone").Value;
  27. model.ZipCode = result.FirstOrDefault(x => x.Key == "ZipCode").Value;
  28. model.Address = result.FirstOrDefault(x => x.Key == "Address").Value;
  29. model.WeChatCode = result.FirstOrDefault(x => x.Key == "WeChatCode").Value;
  30. model.MicroBlog = result.FirstOrDefault(x => x.Key == "MicroBlog").Value;
  31. model.NavigationModel = na.GetNavigationTreeByMark("0$15235665423212817$");
  32. model.NavigationHModel = na.GetNavigationTreeByMark("0$15235668675090910$");
  33. model.Record = result.FirstOrDefault(x => x.Key == "Record").Value;
  34. model.LinkList = link.GetEntities();
  35. return model;
  36. }
  37. }
  38. }