public async Task <IActionResult> Profile() { try { var authorize = Barayand.Common.Services.TokenService.AuthorizeUser(Request); if (authorize < 1) { if (authorize == 0) { Response.Cookies.Delete("HomeKitoUser"); } return(RedirectToAction("Index", new { redirect = "/User/Profile" })); } UserModel userModel = await _repository.GetById(authorize); if (userModel == null) { return(RedirectToAction("Index", new { redirect = "/User/Profile" })); } List <InvoiceModel> invoices = ((List <InvoiceModel>)(await _invoicerepository.GetAll()).Data); invoices = (invoices != null) ? invoices.Where(x => x.I_Status > 0 && x.I_UserId == authorize).ToList() : null; List <InvoiceModel> FivaLastInvoices = new List <InvoiceModel>(); List <OfflinRequestModel> OfflineRequests = ((List <OfflinRequestModel>)(await _offreqrepository.GetAll()).Data).Where(x => x.O_User == authorize).ToList(); if (invoices != null) { FivaLastInvoices = invoices.Take(5).ToList(); } else { FivaLastInvoices = null; } ViewBag.Favorites = await _favoritrepostory.GetByUser(authorize); ViewBag.WalletHistory = await _walletrepository.GetAllUserTransactions(authorize); ViewBag.LastInvoices = FivaLastInvoices; ViewBag.UserInvoices = invoices; ViewBag.OfflineRequests = OfflineRequests; return(View(userModel)); } catch (Exception ex) { return(null); } }