public async Task <IActionResult> Index() { try { var loggedUser = JsonConvert.DeserializeObject <TelefonicaModel.User>(HttpContext.Session.GetString("LoggedUser")); var userRole = HttpContext.Session.GetString("UserRole"); ViewData["loggedUser"] = loggedUser; ViewData["userRole"] = userRole; var clientList = _telefonicaApi.GetCurrentClients(); ViewData["clientList"] = clientList; var userList = await _telefonicaApi.GetUsers(); ViewData["userList"] = userList; _telefonicaApi.SetCurrentProposal(null); if (userRole.Equals(Enum.GetName(typeof(Dto.Dto.UserRole), Dto.Dto.UserRole.Administrator))) { var proposals = await _telefonicaApi.GetProposals(); return(View("../UserProposal/ProposalList", proposals)); } else { var proposals = await _telefonicaApi.GetProposalsByUser(loggedUser.Id.ToString()); return(View("../UserProposal/ProposalList", proposals)); } }catch (Exception ex) { var extraData = new { step = "ex", from = "UI" }; var log = new Log() { Reference = "UserIndex", Messsage = ex.Message, ExtraData = extraData }; await _telefonicaApi.InsertLog(log); var proposals = new List <Proposal>(); ViewBag.ErrorMessage = "Error al cargar lista de propuestas"; return(View("../UserProposal/ProposalList", proposals)); } }