Ejemplo n.º 1
0
        public ActionResult editarUsuario(long user_id)
        {
            exist_users    user   = new exist_users();
            Exist_UsersDto Models = new Exist_UsersDto();

            Models = user.consultarUsuario(user_id);
            string cSenha  = Request.Form["user_password_confirm"];
            object retorno = new object();

            RemoveReferences(ModelState, "user_country");

            if (Models.countries.country_id == 0)
            {
                ModelState.AddModelError("user_country.country_id", "pais é obrigatório");
                paises();
                tratamentos();
                string contentView = RenderViewToString("~/Views/Home/editarForm.cshtml", Models);
                return(Json(new { status = "validation", view = contentView }));
            }
            if (!ModelState.IsValid)
            {
                paises();
                tratamentos();
                string contentView = RenderViewToString("~/Views/Home/editarForm.cshtml", Models);
                return(Json(new { status = "validation", view = contentView }));
            }
            retorno = user.Editar(Models);

            if (retorno == "0")
            {
                return(Json(new { status = "validation", message = "Erro ao conectar na Database" }));
            }
            return(Json(new { status = "success", message = "cadastro com sucesso" }));
        }
Ejemplo n.º 2
0
        public ActionResult Excluir(Exist_UsersDto model)
        {
            try
            {
                exist_users user = new exist_users();
                user.Excluir(model.user_id);

                return(Json(new { status = "success" }));
            }
            catch (Exception ex)
            {
                return(Json(new { status = "error" }));
            }
        }
Ejemplo n.º 3
0
        public ActionResult Editar(Exist_UsersDto model)
        {
            try
            {
                RemoveReferences(ModelState, "country_id");
                exist_users exist_users = new exist_users();
                string      retorno     = exist_users.Editar(model);

                return(Json(new { status = "success" }));
            }
            catch (Exception ex)
            {
                return(Json(new { status = "error" }));
            }
        }
Ejemplo n.º 4
0
        public ActionResult Justificar(string user_email, string Justificativa, string email_adm)
        {
            try
            {
                exist_users           user            = new exist_users();
                LoginController       control         = new LoginController();
                List <string>         admsEmail       = new List <string>();
                List <string>         admsEmailMaster = new List <string>();
                countries_for_region  regXpais        = new countries_for_region();
                historic_action_users just            = new historic_action_users();
                long           userCountry;
                long           userReg = 0;
                bool           flag    = true;
                Exist_UsersDto Models  = new Exist_UsersDto();
                string         ip      = GetLocalIpAddress();

                Models          = user.consultarUsuario(user_email);
                userCountry     = Convert.ToInt64(Models.user_country);
                userReg         = regXpais.PegarRegiaoViaPais(userCountry);
                admsEmail       = user.pegarOsAdms(userReg);
                admsEmailMaster = user.pegarOsMasters();
                string aviso = @GeralResource.RecRes(634);

                just.InserirJustificativa(Justificativa, email_adm, Models.user_id, ip);

                foreach (var email in admsEmail)
                {
                    control.JustifyEmail(email, aviso);
                }
                foreach (var email in admsEmailMaster)
                {
                    control.JustifyEmail(email, aviso);
                }

                control.JustifyEmail(user_email, aviso);
                ViewBag.mensagem = @GeralResource.RecRes(582);

                user.BlockUser(Models.user_id);

                return(Json(new { status = "success", message = @GeralResource.RecRes(582), JsonRequestBehavior.AllowGet }));
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 5
0
        public ActionResult Adms_do_sistema()
        {
            Exist_UsersDto           usuario;
            Exist_UsersDtoCollection adms = new Exist_UsersDtoCollection();
            exist_users util = new exist_users();

            adms    = util.ConsultarTodosAdms();
            usuario = getUser();
            paises();
            tratamentos();
            ViewBag.usuario = usuario;
            var SchemeList = (from scheme in adms select scheme).ToList();

            ViewBag.Adms_do_Sistema = adms;

            return(View("~/Views/Adms_do_sistema/Adms_do_Sistema.cshtml", SchemeList));
        }
Ejemplo n.º 6
0
        public Exist_UsersDto getUser()
        {
            try
            {
                exist_users util = new exist_users();

                var usuario = (Exist_UsersDto)Session["usuario"];
                if (usuario != null)
                {
                    usuario = util.consultarUsuario(usuario.user_id);
                }

                return(usuario);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 7
0
        public ActionResult Atualizar_Usuarios()
        {
            Exist_UsersDto           usuario;
            Exist_UsersDtoCollection usuarios = new Exist_UsersDtoCollection();
            exist_users util = new exist_users();

            usuario = getUser();

            usuarios = util.ConsultarUsuarios();
            paises();
            tratamentos();
            ViewBag.usuario = usuario;

            var SchemeList = (from scheme in usuarios select scheme).ToList();

            ViewBag.usuarios = usuarios;

            return(View("~/Views/Atualizar_Usuarios/Atualizar_Usuarios.cshtml", SchemeList));
        }
Ejemplo n.º 8
0
        public ActionResult AlterarCurrency(string currency)
        {
            try
            {
                var  usuario     = getUser();
                long currency_id = Convert.ToInt64(currency);
                if (usuario.currency_id != currency_id)
                {
                    exist_users exist_users = new exist_users();
                    string      retorno     = exist_users.AlterarMoeda(currency_id, usuario.user_id);
                    usuario.currency_id = currency_id;
                    Session["usuario"]  = usuario;
                }

                return(Json(new { status = "success" }));
            }
            catch (Exception ex)
            {
                return(Json(new { status = "error" }));
            }
        }
Ejemplo n.º 9
0
        public ActionResult Incluir(Exist_UsersDto model)
        {
            try
            {
                RemoveReferences(ModelState, "country_id");

                //if (!ModelState.IsValid)
                //{
                //    return Json(new { status = "validation", view = "" });
                //}

                exist_users exist_users = new exist_users();
                string      retorno     = exist_users.Incluir(model);


                return(Json(new { status = "success" }));
            }
            catch (Exception ex)
            {
                return(Json(new { status = "error" }));
            }
        }
Ejemplo n.º 10
0
        public ActionResult AlterarSenha(Exist_UsersDto Models)
        {   // alterar senha quando o usuario digitou senha temporaria
            try
            {
                exist_users user     = new exist_users();
                string      cSenha   = Request.Form["user_password_confirm"];
                string      truePass = Models.user_password;
                Models = user.consultarUsuario(Models.user_id);
                Models.user_password         = truePass;
                Models.user_password_confirm = cSenha;
                RemoveReferences(ModelState, "user_country");

                if (Models.user_password != Models.user_password_confirm)
                {
                    ModelState.AddModelError("user_password", GeralResource.RecRes(120));
                    paises();
                    tratamentos();
                    string contentView = RenderViewToString("~/Views/Home/FormPass.cshtml", Models);
                    return(Json(new { status = "validation", view = contentView }));
                }
                if (CalculateEntropy(Models.user_password) < 2)
                {
                    ModelState.AddModelError("user_password", GeralResource.RecRes(626));
                    paises();
                    tratamentos();
                    string contentView = RenderViewToString("~/Views/Home/FormPass.cshtml", Models);
                    return(Json(new { status = "validation", view = contentView }));
                }
                string retorno = user.AlterarSenha(Models);
                if (retorno != "1")
                {
                }
                return(Json(new { status = "success", message = GeralResource.RecRes(448) }));
            }
            catch (Exception ex)
            {
                return(Json(new { status = "error", message = GeralResource.RecRes(561) }));
            }
        }
Ejemplo n.º 11
0
        public ActionResult LoadGridUsuarios(string texto, string coluna)
        {
            try
            {
                List <Exist_UsersDto> usuarios = new List <Exist_UsersDto>();
                if (texto != null)
                {
                    if (texto == "")
                    {
                        exist_users exist_users = new exist_users();
                        usuarios = exist_users.ConsultarUsuarios();
                        usuarios = usuarios.Where(f => f.user_admin == false).ToList();
                        TempData["collection_users"] = usuarios;
                    }
                    else
                    {
                        usuarios = (List <Exist_UsersDto>)TempData["collection_users"];
                        TempData.Keep("collection_users");
                        usuarios            = Buscar(usuarios, texto, coluna);
                        ViewBag.defaultSort = coluna;
                    }
                }
                else
                {
                    usuarios = (List <Exist_UsersDto>)TempData["collection_users"];
                    TempData.Keep("collection_users");
                }

                var SchemeList = (from scheme in usuarios select scheme).ToList();

                return(PartialView("GridUsuarios", SchemeList));
            }
            catch (Exception ex)
            {
                return(Content("<label> Erro. Contacte o administrador </label>"));
            }
        }
Ejemplo n.º 12
0
        // GET: Home

        public ActionResult License(string emailUser, string aprovar, string lang, string emailAdm)
        {
            LoginController       utilidade = new LoginController();
            exist_users           user      = new exist_users();
            Exist_UsersDto        Models    = new Exist_UsersDto();
            Exist_UsersDto        adm       = new Exist_UsersDto();
            historic_action_users just      = new historic_action_users();


            byte[] byteEmailUser = System.Convert.FromBase64String(emailUser.Replace(" ", ""));
            emailUser = System.Text.Encoding.UTF8.GetString(byteEmailUser);

            byte[] byteEmailAdmin = System.Convert.FromBase64String(emailAdm.Replace(" ", ""));
            emailAdm = System.Text.Encoding.UTF8.GetString(byteEmailAdmin);

            //  emailUser = PwdEncript.criptograph.Descriptografar(emailUser);
            // emailAdm = PwdEncript.criptograph.Descriptografar(emailAdm);

            Models = user.consultarUsuario(emailUser);
            adm    = user.consultarUsuario(emailAdm);
            string ip = GetLocalIpAddress();

            bool userIsnew = true;
            bool approve   = false;

            if (adm == null)
            {
                return(Content("<label>" + @GeralResource.RecRes(580) + "</label>"));
            }
            if (adm.user_accesslevel < 1)
            {
                return(Content("<label>" + @GeralResource.RecRes(580) + "</label>"));
            }

            if (aprovar == "1")
            {
                approve = true;
            }
            userIsnew = user.IsNewUser(Models.user_id);

            if (!approve)
            {
                ViewBag.mensagem = "";
                ViewBag.user     = emailUser;
                ViewBag.data     = DateTime.Now;
                ViewBag.email    = emailAdm;
                ViewBag.approve  = 0;
                user.SetAction2(Models);
            }
            else
            {
                if (Models.user_date_expire != null)
                {
                    if (Models.user_date_expire > DateTime.Now)
                    {
                        ViewBag.mensagem = @GeralResource.RecRes(138);
                        ViewBag.approve  = 1;
                    }
                }
                else
                {
                    ViewBag.mensagem = @GeralResource.RecRes(138);
                    ViewBag.approve  = 1;
                    user.license(Models.user_id);
                    just.InserirJustificativa(emailAdm, Models.user_id, ip);
                }
            }
            return(View());
        }