// GET: Groups public ActionResult Index() { GroupIndexViewModel model = new GroupIndexViewModel(); model.Groups = Facade.GetAllGroups(); return(View(model)); }
// GET: GroupExpense public ActionResult Index() { List <SelectListItem> list = new List <SelectListItem>(); // Find GroupId of particular user var GroupIds = dbContext.TbGroupUser.Where( t => t.UserId.Equals( dbContext.Users.FirstOrDefault(u => u.UserName.Equals(User.Identity.Name)).Id ) ).Select(t => t.GroupId); // Find GroupNames of particular user foreach (int grpId in GroupIds) { list.Add( new SelectListItem() { Text = dbContext.TbGroup.FirstOrDefault(t => t.GroupId.Equals(grpId)).GroupName, Value = grpId.ToString() }); } ; GroupIndexViewModel model = new GroupIndexViewModel() { GroupsList = list, CreateGroupVM = new CreateGroupViewModel() }; return(View(model)); }
public IActionResult Preferences(GroupIndexViewModel model, String submit, int minseats, int maxseats) { var value = HttpContext.Session.GetString("pref"); var pref = value == null ? new GroupIndexViewModel() : JsonConvert.DeserializeObject <GroupIndexViewModel>(value); System.Console.WriteLine("min seats and max seats " + minseats + maxseats); if (submit == "add" && pref.Filters.Count < 2) { Filter filter = new Filter(); Preference preference1 = new Preference(); Preference preference2 = new Preference(); Preference preference3 = new Preference(); filter.Prefs.Add(preference1); filter.Prefs.Add(preference2); filter.Prefs.Add(preference3); pref.Filters.Add(filter); System.Console.WriteLine("THE NUMBER OF FILTERS : " + pref.Filters.Count); HttpContext.Session.SetString("pref", JsonConvert.SerializeObject(pref)); } if (submit == "change") { pref = model; HttpContext.Session.SetString("pref", JsonConvert.SerializeObject(model)); } return(View(pref)); }
// GET: Group /// <summary> /// Created by: Trent Cullinan 03/31/2016 /// Displays list of groups a User belongs to /// /// Modified by: Nicholas King 04/03/2016 /// Merged grouplist display and create group /// added join group list table /// /// </summary> /// <returns></returns> public ActionResult Index() { GroupIndexViewModel model = new GroupIndexViewModel(); int userId = RetrieveUserId(); if (0 != userId) { var groups = new GroupManager().GetUserGroups(userId); model.UserGroupList = new List <GroupIndexViewModel.UserGroupViewModel>(groups.Count()); foreach (Group group in groups) { model.UserGroupList.Add(new GroupIndexViewModel.UserGroupViewModel() { GroupId = group.GroupID, Name = group.Name, LeaderUserName = group.GroupLeader.User.UserName, LeaderEmail = group.GroupLeader.User.EmailAddress, CreatedDate = group.CreatedDate }); } var joinableGroups = new GroupManager().GetGroupsToJoin(userId); model.NonUserGroupList = new List <GroupIndexViewModel.UserGroupViewModel>(joinableGroups.Count()); foreach (Group group in joinableGroups) { if (WebConfigurationManager.AppSettings["ExpertGroup"] != group.Name) { model.NonUserGroupList.Add(new GroupIndexViewModel.UserGroupViewModel() { GroupId = group.GroupID, Name = group.Name, LeaderUserName = group.GroupLeader.User.UserName, LeaderEmail = group.GroupLeader.User.EmailAddress, CreatedDate = group.CreatedDate }); } } return(View(model)); } return(View("Error")); }
public async Task <IActionResult> Index() { ApplicationUser user = await _userManager.GetUserAsync(HttpContext.User); GroupIndexViewModel model = new GroupIndexViewModel { Groups = _repository.GetGroups(Guid.Parse(user.Id)) ?? new List <Group>(), ActiveGroup = _repository.GetUser(Guid.Parse(user.Id)).ActiveGroup }; return(View(model)); }
public static GroupIndexViewModel GetGroupIndexViewModel(ApplicationDbContext db, IPrincipal user) { List <GroupViewModel> GroupsCreatedByOrg = GetGroupsViewCreatedByOrg(db, user); List <GroupViewModel> GroupsContainingOrg = GetGroupsViewContainingOrg(db, EntityStatusEnum.Active, user); //only for Active members GroupIndexViewModel model = new GroupIndexViewModel() { GroupsCreatedByOrg = GroupsCreatedByOrg, GroupsContainingOrg = GroupsContainingOrg }; return(model); }
private async Task GetGroupCategories(GroupIndexViewModel model) { model.GroupCategories = new Dictionary <int, List <string> >(); foreach (Group group in model.AllGroups) { List <string> groupCategories = await _context.Group_GroupCategories .Include(ggc => ggc.GroupCategory) .Where(ggc => ggc.GroupId == group.Id) .Select(ggc => ggc.GroupCategory.Name) .ToListAsync(); model.GroupCategories.Add(group.Id, groupCategories); } }
public async Task <IActionResult> ByCategory(int id) { GroupIndexViewModel model = new GroupIndexViewModel(); model.ByCategory = await _context.GroupCategories.Where(gc => gc.Id == id).Select(gc => gc.Name).FirstOrDefaultAsync(); model.AllGroups = await _context.Group_GroupCategories .Include(ggc => ggc.Group) .Where(ggc => ggc.GroupCategoryId == id) .Select(ggc => ggc.Group) .ToListAsync(); await GetGroupCategories(model); return(View("Index", model)); }
public async Task <IActionResult> Index(string userId) { GroupIndexViewModel model = new GroupIndexViewModel(); model.UserId = userId; if (userId != null && userId != "") { model.AllGroups = await _context.GroupMembers .Include(gm => gm.Group) .Where(gm => gm.ApplicationUserId == userId) .Select(gm => gm.Group) .ToListAsync(); model.ActualUserAsGroupCoordinator = await _context.GroupMembers .Include(gmp => gmp.GroupMemberProfile) .Where(gm => gm.ApplicationUserId == userId && gm.GroupMemberProfile.Name == GroupMemberProfilesData.Coordinator) .Select(gm => gm.GroupId) .ToListAsync(); model.ActualUserAsGroupMember = await _context.GroupMembers .Include(gmp => gmp.GroupMemberProfile) .Where(gm => gm.ApplicationUserId == userId && gm.GroupMemberProfile.Name == GroupMemberProfilesData.Member) .Select(gm => gm.GroupId) .ToListAsync(); await GetGroupCategories(model); return(View(model)); } else { model.AllGroups = await _context.Groups.ToListAsync(); model.ActualUserAsGroupCoordinator = null; model.ActualUserAsGroupMember = null; await GetGroupCategories(model); return(View(model)); } }
// GET: Groups public ActionResult Index() { GroupIndexViewModel model = GroupViewHelpers.GetGroupIndexViewModel(db, User); return(View(model)); }