Ejemplo n.º 1
0
        public async Task <IActionResult> OpenProposalFinished(Proposal proposal)
        {
            try
            {
                var loggedUser = JsonConvert.DeserializeObject <TelefonicaModel.User>(HttpContext.Session.GetString("LoggedUser"));
                var userRole   = HttpContext.Session.GetString("UserRole");
                ViewData["loggedUser"] = loggedUser;
                ViewData["userRole"]   = userRole;
                var planDefList = _telefonicaApi.PopulateDefinitivePlanList(proposal);
                _telefonicaApi.SetCurrentDefinitivePlans(planDefList);
                var mobileList = _mapper.Map <List <DevicePymesModel> >(proposal.Equipos);
                _telefonicaApi.SetConfirmedEquiposPymes(mobileList);
                ViewData["planDefList"] = planDefList;
                List <SuggestorB2b> plansList = await _telefonicaApi.GetSuggestedPlansByRut(proposal.RutCliente);

                var planMapped = _mapper.Map <List <SuggestorB2b>, List <SuggestorB2bModel> >(plansList);
                ViewData["suggestorLines"] = planMapped;
                ViewData["companyName"]    = proposal.ClientName;

                return(View("ProposalDetails", proposal));
            }
            catch (Exception ex)
            {
                var extraData = new { step = "ex", from = "UI" };
                var log       = new Log()
                {
                    Reference = "OpenProposalFinished",
                    Messsage  = ex.Message,
                    ExtraData = extraData
                };

                await _telefonicaApi.InsertLog(log);

                var proposals = new List <Proposal>();
                ViewBag.ErrorMessage = "Error al cargar los detalles de la propuesta";
                return(View("ProposalDetails", proposals));
            }
        }