public async Task <IActionResult> Index() { //Get a list of Accounts for a user var userAccount = await CommonContext.UserAccounts.Include(m => m.Account).ThenInclude(m => m.Partition).Where(m => m.UserId == User.GetLoggedInUserId().Value).ToListAsync(); var citations = new List <Citation>(); //CitationListModel model = new CitationListModel(); //Loop through each AccountContext for this user and get a list of Citations foreach (var commonAccount in userAccount) { //Get the correct account database based on the partition that was chosen for the account. var accountCtx = ContextsUtility.CreateAccountContext(Cryptography.Decrypt(commonAccount.Account.Partition.ConnectionString)); var citationsForAccount = accountCtx.Citations.Include(x => x.Account) .Include(x => x.Violation) .Include(x => x.AssignedTo) .Include(m => m.Attachments).ThenInclude(m => m.Attachment) .OrderByDescending(x => x.CreateUtc) .Where(m => m.AccountId == commonAccount.AccountId) .AsQueryable(); citations.AddRange(citationsForAccount); // citations.AddRange(new CitationListModel { AccountId= citationsForAccount. }); } CitationListViewModel model = new CitationListViewModel(); model.CitationList = Mapper.Map <List <CitationListModel> >(citations); model.AccountList = Mapper.Map <List <AccountUserList> >(userAccount); return(View(model)); }
public CitationListPage() { InitializeComponent(); BindingContext = _viewModel = App.Current.Services.GetService <CitationListViewModel>(); }