/// <summary> /// Detail view /// </summary> /// <param name="id"></param> /// <returns>Detail view about group</returns> public async Task <IActionResult> Detail(int id) { var groupDto = await _groupService.GetGroupAsync(id); var profilesDto = await _groupService.GetAsyncProfilesByGroup(id); var transactionsDto = await _transactionsService.GetTransactionsAsync(id); var scoreList = await _transactionsService.HowMatchPayAsync(id); var usersScore = await _transactionsService.ScoreAsync(id); var userScore = new List <UsersScore>(); var resultScore = new List <UsersScore>(); var transactionsUser = new List <UsersTransaction>(); var groupUrl = Url.Action( "AddUser", "Group", new { groupHash = groupDto.Guid }, protocol: HttpContext.Request.Scheme); foreach (var transaction in scoreList) { var user = await _profileService.GetProfileById(transaction.Creditor); userScore.Add(new UsersScore { LastNameCreditor = user.LastName, FirstNameCreditor = user.FirstName, Summ = transaction.Summ }); } foreach (var score in usersScore) { var creditor = await _profileService.GetProfileById(score.Creditor); var debitor = await _profileService.GetProfileById(score.Debitor); resultScore.Add(new UsersScore { LastNameCreditor = creditor.LastName, FirstNameCreditor = creditor.FirstName, MiddleNameCreditor = creditor.MiddleName, LastNameDebitor = debitor.LastName, FirstNameDebitor = debitor.FirstName, MiddleNameDebitor = debitor.MiddleName, Summ = score.Summ }); } foreach (var transaction in transactionsDto) { var transactionStatus = await _transactionsService.CheckUsersInTransactionAsync(transaction.Id); transactionsUser.Add(new UsersTransaction { Id = transaction.Id, Description = transaction.Description, Comment = transaction.Comment, Amount = transaction.Amount, CurrencyType = transaction.CurrencyType, CreationTime = transaction.CreationTime, ProfileId = transaction.ProfileId, GroupId = transaction.GroupId, Guid = transaction.Guid, Status = transactionStatus }); } var groupViewModel = new GroupViewModel { Id = groupDto.Id, Title = groupDto.Title, Description = groupDto.Description, Profiles = profilesDto, Transactions = transactionsUser, GroupUrl = groupUrl, Scores = userScore, UsersScore = resultScore }; return(View(groupViewModel)); }