using BuddyFinance.Admin.Controllers; using BuddyFinance.Admin.Models; using BuddyFinance.Common.Integration; using BuddyFinance.Integration.Models.Profiles; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace BuddyFinance.Admin.Areas.Admin.Controllers { [Area("Admin")] public class FindController : BaseController { private readonly IHttpContextAccessor httpContextAccessor; public FindController(IConfiguration configuration, BuddyFinanceDbContext dbContext, IHttpContextAccessor httpContextAccessor) : base(configuration, dbContext) { this.httpContextAccessor = httpContextAccessor; } public IActionResult Profile(bool mutliple = false) { ViewData["Multiple"] = mutliple; var profiles = httpContextAccessor.HttpContext.Session.Get>("ApprovedLenders"); if (profiles == null || !profiles.Any()) { var apiResponse = WebApiHelper.Get($"{API_BASE}profiles/", "approvedLenders", _token); if (apiResponse.ErrorCode == 0) { if (apiResponse.Result.ErrorCode == 0) { profiles = apiResponse.Result.Result; httpContextAccessor.HttpContext.Session.Set("ApprovedLenders", profiles); } else { TempData["Message"] = $"could not load profiles.{apiResponse.Result.ErrorMessage}"; } } else { TempData["Message"] = $"could not load profiles.{apiResponse.ErrorMessage}"; } } return PartialView(profiles); } } }