Exemple #1
0
        public async Task <IActionResult> Index()
        {
            var loggedUser = JsonConvert.DeserializeObject <TelefonicaModel.User>(HttpContext.Session.GetString("LoggedUser"));

            if (loggedUser != null)
            {
                try
                {
                    _telefonicaApi.EmptyEquipoPymesCurrentList();
                    var clientList = _telefonicaApi.GetCurrentClients();
                    ViewData["loggedUser"] = loggedUser;
                    ViewData["userRole"]   = HttpContext.Session.GetString("UserRole");
                    var planesOfertList = _telefonicaApi.GetActualPlans();
                    ViewData["movileDevices"] = _telefonicaApi.GetEquiposPymesList();
                    ViewData["planOfertList"] = planesOfertList;
                    var planMapped = new List <SuggestorB2bModel>();
                    if (clientList != null && clientList.Count > 0)
                    {
                        ViewData["clientList"] = clientList;
                        List <SuggestorB2b> plansList = await _telefonicaApi.GetSuggestedPlansByRut(clientList[0].Documento);

                        planMapped = _mapper.Map <List <SuggestorB2b>, List <SuggestorB2bModel> >(plansList);
                        _telefonicaApi.UpdateCurrentClient(clientList[0].Documento);
                        var indexes = _telefonicaApi.CalculateIndexes();
                        ViewData["Indexes"] = indexes;
                    }
                    ViewData["planDefList"]   = _telefonicaApi.GetCurrentDefinitivePlans();
                    ViewData["mobileList"]    = new List <DevicePymesModel>();
                    ViewData["devicePayment"] = 0;
                    ViewData["subsidy"]       = 0;
                    ViewData["payback"]       = 0;
                    ViewData["currentClient"] = "null";
                    _telefonicaApi.SetCurrentProposal(null);

                    return(View("../Home/Suggestor", planMapped));
                }
                catch (Exception ex) {
                    var extraData = new { step = "ex", from = "UI" };
                    var log       = new Log()
                    {
                        Reference = "suggestorIndex",
                        Messsage  = ex.Message,
                        ExtraData = extraData
                    };

                    await _telefonicaApi.InsertLog(log);

                    ViewBag.ErrorMessage = "Error al cargar los elemenos";
                    var planMapped = new List <SuggestorB2bModel>();
                    return(View("../Home/Suggestor", planMapped));
                }
            }
            else
            {
                ViewBag.ErrorMessage = "No se encuentra logueado";
                return(View("../Login/Login"));
            }
        }
Exemple #2
0
        public async Task <IActionResult> OpenProposalToEdit(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 clientList = _telefonicaApi.GetCurrentClients();
                ViewData["clientList"] = clientList;
                var planesOfertList = _telefonicaApi.GetActualPlans();
                ViewData["movileDevices"] = _telefonicaApi.GetEquiposPymesList();

                ViewData["planOfertList"] = planesOfertList;
                List <SuggestorB2b> plansList = await _telefonicaApi.GetSuggestedPlansByRut(proposal.RutCliente);

                _telefonicaApi.UpdateCurrentClient(proposal.RutCliente);
                var planMapped  = _mapper.Map <List <SuggestorB2b>, List <SuggestorB2bModel> >(plansList);
                var planDefList = PopulateDefinitivePlanList(proposal);
                ViewData["loggedUser"] = loggedUser;
                ViewData["userRole"]   = HttpContext.Session.GetString("UserRole");
                _telefonicaApi.SetCurrentDefinitivePlans(planDefList);
                ViewData["planDefList"] = planDefList;
                var indexes = _telefonicaApi.CalculateIndexes();
                ViewData["Indexes"] = indexes;
                var mobilePymesList = _mapper.Map <List <DevicePymesModel> >(proposal.Equipos);
                ViewData["mobileList"]    = mobilePymesList;
                ViewData["devicePayment"] = proposal.DevicePayment;
                ViewData["subsidy"]       = proposal.Subsidio;
                ViewData["payback"]       = proposal.Payback;

                // ViewBag.Client = proposal.RutCliente;
                ViewData["currentClient"] = proposal.RutCliente;

                _telefonicaApi.SetCurrentEquiposPymesList(mobilePymesList);
                _telefonicaApi.SetConfirmedEquiposPymes(mobilePymesList);

                return(View("../Home/Suggestor", planMapped));
            }
            catch (Exception ex)
            {
                var extraData = new { step = "ex", from = "UI" };
                var log       = new Log()
                {
                    Reference = "SendMailSug",
                    Messsage  = ex.Message,
                    ExtraData = extraData
                };

                await _telefonicaApi.InsertLog(log);

                var planMapped = new List <SuggestorB2bModel>();
                ViewBag.ErrorMessage = "Error al cargar detalles de la propuesta";
                return(View("../Home/Suggestor", planMapped));
            }
        }
        public async Task <IActionResult> Index(Proposal proposal)
        {
            try
            {
                List <SuggestorB2b> plansList = await _telefonicaApi.GetSuggestedPlansByRut(proposal.RutCliente);

                var planMapped = _mapper.Map <List <SuggestorB2b>, List <SuggestorB2bModel> >(plansList);
                ViewData["suggestorLine"] = planMapped;
                return(View("../UserProposal/ProposalDetails", proposal));
            }
            catch (Exception ex)
            {
                var extraData = new { step = "ex", from = "UI" };
                var log       = new Log()
                {
                    Reference = "proDetailsIndex",
                    Messsage  = ex.Message,
                    ExtraData = extraData
                };

                var logged = await _telefonicaApi.InsertLog(log);

                ViewBag.ErrorMessage = "Error al cargar los detalles de la propuesta";
                return(View());
            }
        }