public ActionResult Index(string id) { var viewModel = new ProfilesIndexViewModel { Theme = _themeSettingsService.GetTheme(id), Profiles = _themeSettingsService.GetProfiles(id).ToList() }; return(View(viewModel)); }
public ActionResult Index() { var currentProfileId = UnitOfWork.ProfileRepository.GetProfileId(User.Identity.GetUserId()); // Hämtar en dictionary med alla användarens kontakter och kategorier var acceptedContactsAndCategories = UnitOfWork.ContactRepository.FindContactsAndCategories(currentProfileId); // Hämtar obesvarade kontaktförfrågningar var pendingContactIds = UnitOfWork.ContactRepository.FindContactIds(currentProfileId, false); var profilesContactsPending = UnitOfWork.ProfileRepository.FindProfiles(pendingContactIds); var listOfProfileContactViewModel = new List <ContactProfileViewModel>(); var profilesIndexViewModelContactsPending = new ProfilesIndexViewModel(); // Itererar igenom kontakter foreach (var item in acceptedContactsAndCategories) { // Om kontakten är aktiv, läggs den till en lista if (item.Key.Active == true) { var profileContactViewModel = new ContactProfileViewModel(item.Key, item.Value); listOfProfileContactViewModel.Add(profileContactViewModel); } } // Itererar igenom förfrågningar foreach (var model in profilesContactsPending) { if (model.Active == true) { var profileIndexViewModelPending = new ProfileIndexViewModel(model); profilesIndexViewModelContactsPending.Profiles.Add(profileIndexViewModelPending); } } // Skapar en viewmodel med både kontaktförfrågningar och kontakter var allContacts = new ContactsViewModel(listOfProfileContactViewModel, profilesIndexViewModelContactsPending); return(View(allContacts)); }
public ActionResult Index() { var viewModels = new ProfilesIndexViewModel(); // Om ett konto precis inaktiverats, får viewbag:en en bekräftelse som skickas vidare till view ViewBag.Deactivated = TempData["Deactivated"]; try { var profilesCount = UnitOfWork.ProfileRepository.CountProfiles(); // Kontrollerar om det finns tillräckligt med profiler för att göra profilkorten på startsidan if (profilesCount > 3) { foreach (var item in UnitOfWork.ProfileRepository.GetThreeNewestUsers()) { var viewModel = new ProfileIndexViewModel(item); viewModels.Profiles.Add(viewModel); } UnitOfWork.Dispose(); return(View(viewModels)); } else { UnitOfWork.Dispose(); return(View(viewModels)); } } // Inga profiler kunde hämtas från databasen catch (InvalidOperationException) { return(View(viewModels)); } }
public ContactsViewModel(List <ContactProfileViewModel> accepted, ProfilesIndexViewModel pending) { Accepted = accepted; Pending = pending; }