Example #1
0
        public async Task <IActionResult> BuscarQuejas(string region, string departamento, string municipio, string estado, string del, string al, string nombre)
        {
            ClsPeticiones peticiones = new ClsPeticiones();
            AdminSession  session = new AdminSession(HttpContext);
            DateTime?     Del = null, Al = null;

            if (!del.Equals("0"))
            {
                try
                {
                    Del = DateTime.Parse(del);
                }
                catch (Exception)
                {
                }
            }

            if (!al.Equals("0"))
            {
                try
                {
                    Al = DateTime.Parse(al);
                }
                catch (Exception)
                {
                }
            }

            int.TryParse(region, out int IdRegion);
            int.TryParse(departamento, out int IdDepartamento);
            int.TryParse(municipio, out int IdMunicipio);
            int.TryParse(estado, out int IdEstado);


            ClsFiltrosInformesQuejas model = new ClsFiltrosInformesQuejas()
            {
                IdRegion       = IdRegion,
                IdDepartamento = IdDepartamento,
                IdMunicipio    = IdMunicipio,
                IdEstado       = IdEstado,
                Del            = Del,
                Al             = Al,
                Nombrecomercio = nombre.Equals("null") ? null : nombre
            };



            var result = await peticiones.PostComplejoAutenticado <ClsFiltrosInformesQuejas, Cls_Response <List <ClsInfoInformQuejas> > >(model, "Informes/GetInformeQuejas", session.GetClaim(VariablesDeSession.Token));

            if (!result.Error)
            {
                ViewBag.Lista = result.Body;
                session.SetObject(VariablesDeSession.DataReporte, result.Body);
            }
            else
            {
                ViewBag.Error = result.Message;
            }
            return(PartialView());
        }
        public async Task <IActionResult> GuardarEstablecimiento(ClsCreateEstablecimiento model)
        {
            ClsPeticiones peticiones = new ClsPeticiones();
            ClsCatalogos  catalogos  = new ClsCatalogos();
            List <int>    ids        = new List <int> {
                1, 2
            };

            ViewBag.ListEstados        = new SelectList(await catalogos.ListEstados(ids), "IdEstado", "NombreEstado");
            ViewBag.ListaDepartamentos = new SelectList(await catalogos.ListDepartamentos(), "IdDepartamento", "NombreDepartamento");
            AdminSession session = new AdminSession(HttpContext);

            if (ModelState.IsValid)
            {
                model.Establecimiento.IdEmpresa = int.Parse(session.GetString(VariablesDeSession.IdEmpresa));
                var response = await peticiones.PostComplejoAutenticado <TbEstablecimiento, Cls_Response <string> >(model.Establecimiento, "Comercios/GuardarEstablecimiento", session.GetClaim(VariablesDeSession.Token));

                if (!response.Error)
                {
                    session.SetString(response.Body, VariablesDeSession.MensajeExito);
                    return(RedirectToAction("AdminEstablecimientos", "Comercios", new { IdEmpresa = session.GetString(VariablesDeSession.IdEmpresa) }));
                }
                else
                {
                    ViewBag.Error = response.Message;
                    return(View("AdminEstablecimientos", model));
                }
            }
            else
            {
                return(View("AdminEstablecimientos", model));
            }
        }
Example #3
0
        public async Task <IActionResult> ResolverQueja(List <ClsInfoInformQuejas> model)
        {
            ClsPeticiones peticiones = new ClsPeticiones();
            AdminSession  sesion     = new AdminSession(HttpContext);
            bool          ok         = true;

            foreach (var item in model)
            {
                if (item.check && string.IsNullOrEmpty(item.DescripcioResuelve))
                {
                    ok = false;
                }
            }

            if (ok)
            {
                var response = await peticiones.PostComplejoAutenticado <List <ClsInfoInformQuejas>, Cls_Response <string> >(model, "Quejas/AtenderQuejas", sesion.GetClaim(VariablesDeSession.Token));

                if (!response.Error)
                {
                    sesion.SetString(response.Body, VariablesDeSession.MensajeExito);
                    return(RedirectToAction("AtenderQueja", "Quejas"));
                }
                else
                {
                    return(View("AtenderQueja", model));
                }
            }
            else
            {
                return(View("AtenderQueja", model));
            }
        }
Example #4
0
        public async Task <IActionResult> PostLogin(ClsLogin model)
        {
            if (ModelState.IsValid)
            {
                AdminSession  session  = new AdminSession(HttpContext);
                ClsPeticiones peticion = new ClsPeticiones();

                var response = await peticion.PostComplejo <ClsLogin, Cls_Response <ClsInfoUsuario> >(model, "AdmonUsuarios/Login");

                if (!response.Error)
                {
                    var claims = new List <Claim>();
                    claims.Add(new Claim(ClaimTypes.Role, response.Body.NombreRol));
                    claims.Add(new Claim(VariablesDeSession.IdUsuario, response.Body.IdUsuario.ToString()));
                    claims.Add(new Claim(VariablesDeSession.Token, response.Body.JWT));
                    session.SetObject(VariablesDeSession.InfoUsuario, response.Body);

                    var identity  = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
                    var principal = new ClaimsPrincipal(identity);
                    var props     = new AuthenticationProperties();
                    //props.IsPersistent = false;
                    HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, props).Wait();
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ViewBag.Error = response.Message;
                    return(View("Login", model));
                }
            }
            else
            {
                return(View("Login", model));
            }
        }
        public async Task <IActionResult> AdminEstablecimientos(string IdEmpresa)
        {
            ClsPeticiones peticiones = new ClsPeticiones();
            ClsCatalogos  catalogos  = new ClsCatalogos();
            AdminSession  sesion     = new AdminSession(HttpContext);
            List <int>    ids        = new List <int> {
                1, 2
            };

            ViewBag.ListEstados        = new SelectList(await catalogos.ListEstados(ids), "IdEstado", "NombreEstado");
            ViewBag.ListaDepartamentos = new SelectList(await catalogos.ListDepartamentos(), "IdDepartamento", "NombreDepartamento");
            sesion.SetString(IdEmpresa, VariablesDeSession.IdEmpresa);
            //var result = await peticiones.GetComplejoAnonimo<string, Cls_Response<List<ClsInfoSucursales>>>("Comercios/GetEstablecimientosById/" + IdEmpresa);
            ClsCreateEstablecimiento model = new ClsCreateEstablecimiento();

            model.Establecimiento = new TbEstablecimiento();

            if (sesion.GetString(VariablesDeSession.MensajeExito) != null)
            {
                ViewBag.Exito = sesion.GetString(VariablesDeSession.MensajeExito);
                sesion.Remove(VariablesDeSession.MensajeExito);
            }

            return(View(model));
        }
        public async Task <IActionResult> ListarEstablecimientos()
        {
            ClsPeticiones peticiones = new ClsPeticiones();
            AdminSession  sesion     = new AdminSession(HttpContext);
            var           result     = await peticiones.GetComplejoAnonimo <string, Cls_Response <List <ClsInfoSucursales> > >("Comercios/GetEstablecimientosById/" + sesion.GetString(VariablesDeSession.IdEmpresa));

            ViewBag.Lista = result.Body;
            return(PartialView());
        }
Example #7
0
        public async Task <IActionResult> DetalleQueja(string IdQueja)
        {
            ClsPeticiones peticiones = new ClsPeticiones();
            var           response   = await peticiones.GetComplejo <string, Cls_Response <DetalleQueja> >("Quejas/GetQueja/" + IdQueja);

            if (!response.Error)
            {
                ViewBag.Detalle = response.Body;
            }
            else
            {
                ViewBag.Error = response.Message;
            }
            return(PartialView());
        }
Example #8
0
        public async Task <IActionResult> AtenderQueja()
        {
            ClsPeticiones            peticiones = new ClsPeticiones();
            AdminSession             sesion     = new AdminSession(HttpContext);
            ClsFiltrosInformesQuejas model      = new ClsFiltrosInformesQuejas();

            model.IdEstado = 3;
            var result = await peticiones.PostComplejoAutenticado <ClsFiltrosInformesQuejas, Cls_Response <List <ClsInfoInformQuejas> > >(model, "Informes/GetInformeQuejas", sesion.GetClaim(VariablesDeSession.Token));

            if (sesion.GetString(VariablesDeSession.MensajeExito) != null)
            {
                ViewBag.Exito = sesion.GetString(VariablesDeSession.MensajeExito);
                sesion.Remove(VariablesDeSession.MensajeExito);
            }



            return(View(result.Body));
        }
        public async Task <IActionResult> AdminEmpresas()
        {
            ClsPeticiones             peticiones = new ClsPeticiones();
            AdminSession              sesion     = new AdminSession(HttpContext);
            ClsFiltroBusquedaComercio filtros    = new ClsFiltroBusquedaComercio();
            var response = await peticiones.PostComplejoAutenticado <ClsFiltroBusquedaComercio, Cls_Response <List <TbEmpresa> > >(filtros, "Comercios/GetEmpresas", sesion.GetClaim(VariablesDeSession.Token));

            if (!response.Error)
            {
                ViewBag.Lista = response.Body;
            }
            else
            {
                ViewBag.Error = response.Error;
            }


            return(PartialView());
        }
        public async Task <IActionResult> BusquedaComercios(int IdDepto, int IdMuni, string NombreBusqueda)
        {
            ClsPeticiones             peticiones = new ClsPeticiones();
            ClsFiltroBusquedaComercio filtros    = new ClsFiltroBusquedaComercio()
            {
                IdDepto = IdDepto,
                IdMuni  = IdMuni,
                Nombre  = NombreBusqueda.Equals("0")? null:NombreBusqueda
            };
            var response = await peticiones.PostComplejo <ClsFiltroBusquedaComercio, Cls_Response <List <ClsInfoSucursales> > >(filtros, "Comercios/GetComercios");

            if (!response.Error)
            {
                ViewBag.LisComercios = response.Body;
            }
            else
            {
                ViewBag.Error = response.Error;
            }

            return(PartialView());
        }
Example #11
0
        public async Task <IActionResult> GuardarQueja(ClsRegistroQueja model)
        {
            ClsCatalogos catalogos = new ClsCatalogos();

            ViewBag.ListaDepartamentos = new SelectList(await catalogos.ListDepartamentos(), "IdDepartamento", "NombreDepartamento");
            ViewBag.LisCatQueja        = new SelectList(await catalogos.ListCategoriaQueja(), "IdCategoriaQueja", "Nombre");
            ViewBag.Categoria          = new SelectList(await catalogos.ListCategoriaQueja(), "IdCategoriaQueja", "Nombre");
            if (ModelState.IsValid)
            {
                TbQueja queja = new TbQueja
                {
                    Descripcion       = model.DescripcionQueja,
                    IdEstado          = 3,
                    IdEstablecimiento = model.IdComercio,
                    IdCategoriaQueja  = 1
                };

                ClsPeticiones peticiones = new ClsPeticiones();
                var           response   = await peticiones.PostComplejo <TbQueja, Cls_Response <string> >(queja, "Quejas/GuardarQueja");

                if (!response.Error)
                {
                    AdminSession session = new AdminSession(HttpContext);
                    session.SetString(response.Body, VariablesDeSession.MensajeExito);
                    session.SetString(response.Body, VariablesDeSession.MensajeExito);
                    return(RedirectToAction("Registrar", "Quejas"));
                }
                else
                {
                    ViewBag.Error = response.Message;
                    return(View("Registrar", model));
                }
            }
            else
            {
                return(View("Registrar", model));
            }
        }
        public async Task <IActionResult> GuardarEmpresa(ClsCreateEmpresa model)
        {
            ClsCatalogos catalogos = new ClsCatalogos();
            List <int>   ids       = new List <int> {
                1, 2
            };

            ViewBag.ListEstados = new SelectList(await catalogos.ListEstados(ids), "IdEstado", "NombreEstado");
            if (ModelState.IsValid)
            {
                ClsPeticiones peticiones = new ClsPeticiones();
                AdminSession  sesion     = new AdminSession(HttpContext);
                var           response   = await peticiones.PostComplejoAutenticado <TbEmpresa, Cls_Response <string> >(model.Empresa, "Comercios/GuardarEmpresa", sesion.GetClaim(VariablesDeSession.Token));

                if (response != null)
                {
                    if (!response.Error)
                    {
                        sesion.SetString(response.Body, VariablesDeSession.MensajeExito);
                        return(RedirectToAction("RegistrarComercios", "Comercios"));
                    }
                    else
                    {
                        ViewBag.Error = response.Message;
                        return(View("RegistrarComercios", model));
                    }
                }
                else
                {
                    ViewBag.Error = "Error al comunicarse con el servicio.";
                    return(View("RegistrarComercios", model));
                }
            }
            else
            {
                return(View("RegistrarComercios", model));
            }
        }