//[Auth]
        public ActionResult Update(Gerente modelo = null, string CPassword = "", string gerentes = "")
        {
            ViewBag.Respuesta         = null;
            ViewBag.Gerentes          = Funcion.Gerentes();
            ViewBag.Roles             = Funcion.Roles();
            modelo.FechaActualizacion = DateTime.Now;
            bool resultado = false;

            if (System.Web.HttpContext.Current.Session["Rol"] != null)
            {
                ViewBag.Type = System.Web.HttpContext.Current.Session["Rol"].ToString();
            }
            else
            {
                System.Web.HttpContext.Current.Session["Rol"] = "Alto";
            }


            string subEjecutada = System.Web.HttpContext.Current.Session["Rol"].ToString();

            if (Request.HttpMethod == "GET")
            {
                Gerente gerente = new Gerente();
                if (modelo.Id == EngineData.IdActivacion)
                {
                    ViewBag.Type = Funcion.DecodeBase64(EngineData.RegisterManager);
                    gerente      = Metodo.GetGerente(modelo.Email);
                    gerente.FechaActualizacion = DateTime.Now;
                    ViewBag.Type = "Bajo";
                    System.Web.HttpContext.Current.Session["Rol"]     = "Bajo";
                    System.Web.HttpContext.Current.Session["Usuario"] = EngineData.usuarioTemporal;
                    return(View(gerente));
                }
                else
                {
                    if (subEjecutada == "Alto")
                    {
                        ViewBag.Gerentes = Metodo.GetAllGerentes();
                        ViewBag.Type     = "Alto";
                    }
                    else
                    {
                        if (System.Web.HttpContext.Current.Session["Gerente"] != null)
                        {
                            string nombreUsuario = System.Web.HttpContext.Current.Session["Gerente"].ToString();
                            gerente      = Metodo.GetGerenteUserName(nombreUsuario);
                            ViewBag.Type = gerente.Rol;
                        }
                    }
                    gerente.FechaActualizacion = DateTime.Now;
                    return(View(gerente));
                }
            }


            if (Request.HttpMethod == "POST")
            {
                if (gerentes != string.Empty && gerentes != null)
                {
                    modelo.Nombre = gerentes;
                }

                if (subEjecutada == "Alto")
                {
                    if (modelo.Nombre == string.Empty || modelo.NombreUsuario == string.Empty || modelo.Email == string.Empty || modelo.Rol == string.Empty ||
                        modelo.Nombre == null || modelo.NombreUsuario == null || modelo.Email == null || modelo.Rol == null)
                    {
                        ViewBag.Type      = "Alto";
                        ViewBag.Respuesta = "Todos los campos son requeridos, completelos por favor";
                        return(View(modelo));
                    }

                    ViewBag.Gerentes = Metodo.GetAllGerentes();
                }
                else
                {
                    if (modelo.Nombre == string.Empty || modelo.NombreUsuario == string.Empty || modelo.Email == string.Empty || modelo.Password == string.Empty ||
                        CPassword == string.Empty || modelo.Nombre == null || modelo.NombreUsuario == null || modelo.Email == null || modelo.Password == null || CPassword == null)
                    {
                        ViewBag.Respuesta = "Todos los campos son requeridos, completelos por favor 2";
                        return(View(modelo));
                    }
                    resultado = Funcion.CompareString(modelo.Password, CPassword);
                    if (!resultado)
                    {
                        ViewBag.Respuesta = "Las contraseñas deben ser identicas";
                        return(View(modelo));
                    }
                    modelo.Password = Funcion.ConvertirBase64(modelo.NombreUsuario + modelo.Password);
                }
            }

            resultado = Metodo.PutGerente(modelo, subEjecutada);
            if (!resultado)
            {
                ViewBag.Respuesta = "Actualizacion fallida";
            }
            else
            {
                ViewBag.Respuesta = "Actualizacion exitosa";
            }

            if (System.Web.HttpContext.Current.Session["Gerente"] != null)
            {
                string nombreUsuario = System.Web.HttpContext.Current.Session["Gerente"].ToString();
                modelo       = Metodo.GetGerenteUserName(nombreUsuario);
                ViewBag.Type = modelo.Rol;
            }

            return(View(modelo));
        }
Ejemplo n.º 2
0
        public int ResultadoLogin(string password)
        {
            object        obj       = new object();
            int           resultado = 0;
            SqlConnection Conexion  = new SqlConnection(cadenaConexion);

            try
            {
                using (Conexion)
                {
                    Conexion.Open();
                    SqlCommand command = new SqlCommand("Sp_LoginCliente", Conexion);
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Clear();
                    command.Parameters.AddWithValue("@Password", password);
                    obj = command.ExecuteScalar();
                    Conexion.Close();
                }
                if (obj != DBNull.Value && obj != null)
                {
                    resultado = Convert.ToInt32(obj);
                }
            }
            catch (Exception ex)
            {
                Conexion.Close();
                InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/ResultadoLogin*" + Funcion.DecodeBase64(password)));
            }
            return(resultado);
        }
Ejemplo n.º 3
0
        public ActionResult Contact(Respuesta model = null)
        {
            if (model == null || model.Email == string.Empty || model.Email == null)
            {
                return(View(model));
            }

            bool   resultado   = Funcion.EmailEsValido(model.Email);
            string emailCode64 = Funcion.ConvertirBase64(model.Email);

            if (!resultado)
            {
                model = Funcion.RespuestaProceso("Contact", emailCode64, null, model.Email + EngineData.EmailNoValido());
                return(RedirectToAction("State", "Home", model));
            }

            // Suceso al entrar al sitio
            int result = Metodo.ResultadoEntradaAlSitio(model.Email);

            if (result == 1)
            {
                //TIEMPO DE PRUEBA ES VALIDO
                System.Web.HttpContext.Current.Session["Email"]   = model.Email;
                System.Web.HttpContext.Current.Session["Usuario"] = model.Email;
                // Metodo.EstablecerCulturaCliente(model.Email);
                return(RedirectToAction("PlayGame", "Game"));
            }
            else if (result == 2 || result == 4)
            {
                //TIEMPO DE PRUEBA EXPIRO
                Metodo.EstablecerCulturaCliente(model.Email);
                model = Funcion.RespuestaProceso("comprarRegistrarse", emailCode64, null, EngineData.TiempoPruebaJuegoExpiro());
                return(RedirectToAction("State", "Home", model));
            }
            else if (result == 3)
            {
                //CUENTA ACTIVADA CLIENTE REGISTRADO
                //Metodo.EstablecerCulturaCliente(model.Email);
                System.Web.HttpContext.Current.Session["Email"] = model.Email;
                return(RedirectToAction("Login", "Home"));
            }
            else if (result == 5 || result == 7)
            {
                //CUENTA NO ACTIVADA CLIENTE REGISTRADO
                string enlaze = string.Empty;
                // Metodo.EstablecerCulturaCliente(model.Email);
                if (result == 5)
                {
                    string password = Metodo.ObtenerPasswordCliente(model.Email);
                    password  = password.Replace(model.Email, "");
                    resultado = Funcion.EnviarNuevaNotificacion(Notificacion, Metodo, emailCode64, EngineData.Register, password);
                }
                else if (result == 7)
                {
                    resultado = Funcion.EnviarNuevaNotificacion(Notificacion, Metodo, emailCode64, EngineData.Test);
                }
                model = Funcion.RespuestaProceso("Index", emailCode64, null, model.Email + EngineData.CuentaNoActivada());
                return(RedirectToAction("State", "Home", model));
            }
            else if (result == 6)
            {
                // EMAIL NO EXISTE PUEDE PROBAR
                model = Funcion.RespuestaProceso(Funcion.DecodeBase64(EngineData.Test), model.Email, null, null);
                return(RedirectToAction("State", "Home", model));
            }
            return(View(model));
        }