protected IndexViewModel GetClanList() { var clans = new IndexViewModel(); var clanQ = db.Clans.Select(c => new ClanIndexClan { Tag = c.Tag, Name = c.Name, Members = c.Members, BadgeUrl = c.BadgeUrl, Th14Count = c.Th14Count, Th13Count = c.Th13Count, Th12Count = c.Th12Count, Th11Count = c.Th11Count, Th10Count = c.Th10Count, Th9Count = c.Th9Count, Th8Count = c.Th8Count, ThLowCount = c.ThLowCount, WarCount = c.WarCount, MatchPercentage = c.MatchPercentage, WinPercentage = c.WinPercentage, EstimatedWeight = c.EstimatedWeight }); foreach (var clan in clanQ.OrderBy(c => c.Name.ToLower())) { clans.Add(clan); } return(clans); }
public IActionResult Index() { Guid userId = new Guid(_userManager.GetUserId(User)); IndexViewModel models = new IndexViewModel(); List <TodoItem> items = _repository.GetActive(userId).OrderByDescending(i => i.DateCreated).ToList(); foreach (TodoItem item in items.Where(i => i.DateDue.HasValue)) { TodoViewModel model = new TodoViewModel(item.Id, item.Text, item.DateDue, item.IsCompleted); model.Labels = TodoViewModel.GetLabelsRaw(item.Labels); models.Add(model); } foreach (TodoItem item in items.Where(i => !i.DateDue.HasValue)) { TodoViewModel model = new TodoViewModel(item.Id, item.Text, item.DateDue, item.IsCompleted); model.Labels = TodoViewModel.GetLabelsRaw(item.Labels); models.Add(model); } return(View(models)); }
public async Task <IActionResult> Index() { Guid userId = new Guid(_userManager.GetUserId(User)); IndexViewModel model = new IndexViewModel(); List <TodoItem> items = await _repository.GetActiveAsync(userId); foreach (var item in items) { TodoViewModel view = new TodoViewModel(item.Id, item.Text, item.DateDue, item.IsCompleted); model.Add(view); } return(View(model)); }