public async Task <ActionResult> View(int?id) { int userId = id.GetValueOrDefault(CurrentUser.Id.Value); var user = await _userProvider.GetUserById(userId); var userRoles = await GetSortedUserRoles(userId); var userDetails = _detailsBuilder.GetUserDetails(user, userRoles, DetailedInfoType.View); bool isOwner = userId == CurrentUser.Id.Value; var userProfile = _userMapper.ToUserProfile(user, userDetails, isOwner); return(View(userProfile)); }
public async Task <IActionResult> Profile(long id, string filter) { var user = await _usersProvider.GetUserById(id); var allTestSuits = await _testLabProvider.GetAllTestSuits(); var allTests = allTestSuits.SelectMany(p => p.TestCases).ToList(); var model = new UserProfileViewModel { User = user, TestCases = allTests, TotalAutomated = allTests.Count(p => p.Assignee == user && p.Status == Status.Finished), TotalReviewed = allTests.Count(p => p.Reviewer == user && p.Status == Status.Finished), InProgress = allTests.Count(p => p.Assignee == user && (p.Status == Status.InProgress || p.Status == Status.ReviewStarted || p.Status == Status.ReadyForReview || p.Status == Status.ToCrossPlatform)), InReview = allTests.Count(p => p.Reviewer == user && (p.Status == Status.ReviewStarted || p.Status == Status.ChangesRequested || p.Status == Status.Fixed)) }; switch (filter) { case "ta": model.TestCases = model.TestCases.Where(p => p.Assignee == user && p.Status == Status.Finished).ToList(); break; case "tr": model.TestCases = model.TestCases.Where(p => p.Reviewer == user && p.Status == Status.Finished).ToList(); break; case "ip": model.TestCases = model.TestCases.Where(p => p.Assignee == user && (p.Status == Status.InProgress || p.Status == Status.ReviewStarted || p.Status == Status.ReadyForReview || p.Status == Status.ToCrossPlatform)).ToList(); break; case "ir": model.TestCases = model.TestCases.Where(p => p.Reviewer == user && (p.Status == Status.ReviewStarted || p.Status == Status.ChangesRequested || p.Status == Status.Fixed)).ToList(); break; default: model.TestCases = model.TestCases.Where(p => p.Assignee == user).ToList(); break; } return(View(model)); }