public async Task <IActionResult> Profile() { var email = HttpContext.User.Identity.Name; var user = _userRepo.GetUserByEmail(email); DTOLoginUser userToReturn = new DTOLoginUser(); userToReturn.Name = user.Name; userToReturn.Email = user.Email; userToReturn.UserName = user.UserName; userToReturn.Address = user.Address; userToReturn.Gender = user.Gender; userToReturn.Note = user.Note; userToReturn.NbNotes = user.NbNotes; var transactionList = new List <DTOArticle>(); var userTransactions = await _transactionRepo.GetTransactionByUserId(user.Id); foreach (var transaction in userTransactions) { var toInsert = new DTOArticle(); var article = await _articleRepo.GetById(transaction.ArticleId); toInsert.Name = article.Name; toInsert.State = article.State; toInsert.Id = article.Id; if (toInsert.Transaction == null) { toInsert.Transaction = new DTOTransaction(); toInsert.Transaction.TransactionState = transaction.TransactionState; } var sellerFromDb = await _userRepo.GetById(article.SellerId); var sellerToInsert = new DTOUserPublic(); sellerToInsert.Name = sellerFromDb.Name; sellerToInsert.UserName = sellerFromDb.UserName; toInsert.User = sellerToInsert; transactionList.Add(toInsert); } ViewData["transactionlist"] = transactionList; return(View(userToReturn)); }