public ActionResult Notice(int?id) { var vm = new NoticeListViewModel(); if (id.HasValue && id.Value > 0) { vm.Notices = new List <St_notice>(); var nt = DBService.GetEntity <St_notice>(id.Value); if (nt != null && nt.Id > 0) { vm.IsOut = nt.NoticeType == 1; vm.Notices.Add(nt); } } else { vm.Notices = NoticeService.GetLatestNotices(20, 0); } return(View(vm)); }
public ActionResult Index() { var vm = new HomeIndexViewModel(); var vmcache = GetCache(); if (vmcache != null && vmcache is HomeIndexViewModel) { vm = vmcache as HomeIndexViewModel; } else { vm.TopLevelCats = StockService.GetTopLevelStockCats(); vm.HotStocks = StockService.GetHotStocks(10); vm.LatestStocks = StockService.GetlatestStocks(40); if (vm.LatestStocks != null && vm.LatestStocks.Count > 0) { var ids = new List <int>(); foreach (var lst in vm.LatestStocks) { if (lst.CatId.HasValue && lst.CatId.Value > 0 && !ids.Contains(lst.CatId.Value)) { ids.Add(lst.CatId.Value); } } if (ids.Count > 0) { vm.LatestStocksCats = StockService.GetlatestStocksCats(ids); } } vm.RecommendStocks = StockService.GetRecommendStocks(5); vm.LatestNotices = NoticeService.GetLatestNotices(5, 0); AddToCache(vm); } return(View(vm)); }