public ActionResult Details(int?id) { using (var db = new ApplicationDbContext()) { var group = db.UserGroups.Include(g => g.Members).FirstOrDefault(g => g.GroupId == id); if (group != null) { var members = new List <UserViewModel>(); foreach (ApplicationUser member in group.Members) { members.Add(new UserViewModel { UserId = member.Id, Username = member.UserName }); } var model = new UserGroupDetailsViewModel() { GroupId = group.GroupId, Members = members, Name = group.Name }; return(View(model)); } else { return(View("Error")); } } }
public async Task <IActionResult> Details(int id) { var group = await _userService.GetGroup(id); var viewModel = new UserGroupDetailsViewModel() { ChildGroups = string.Join(", ", group.ChildGroups.Select(cg => cg.Name)), Description = group.Description, Id = group.Id, Name = group.Name, ParentGroup = group.ParentGroup.Name }; return(View(nameof(Details), viewModel)); }