Example #1
0
        public ActionResult gvpUsuarioUpdate(CE_Usuario item)
        {
            var model = db1.Usuario;

            if (ModelState.IsValid)
            {
                try
                {
                    var modelItem = model.FirstOrDefault(it => it.usuId == item.usuId);
                    if (modelItem != null)
                    {
                        this.UpdateModel(modelItem);
                        db1.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_gvpUsuario", model.ToList()));
        }
        public ActionResult Login(CE_Usuario usuario, string returnURL, CE_UsuarioPerfil usuper)
        {
            Context db = new Context();

            if (ModelState.IsValid)
            {
                //string username = usuario.usuNome;
                //string password = usuario.usuSenha;
                //string teste = test.perfilPadraoEnumTipo;

                string username = usuario.usuNome;
                string password = usuario.usuSenha;

                bool userValid = db.UsuarioPerfil.Any(user => user.Usuario.usuNome == username && user.Usuario.usuSenha == password);

                // bool b = db.Perfil.Any(a => a.PerfilPadraoEnum.perfilPadraoEnumTipo == teste);

                if (userValid)
                {
                    FormsAuthentication.SetAuthCookie(username, false);
                    if (Url.IsLocalUrl(returnURL) && returnURL.Length > 1 && returnURL.StartsWith("/") &&
                        !returnURL.StartsWith("//") && !returnURL.StartsWith("/\\"))
                    {
                        return(Redirect(returnURL));
                    }
                    else
                    {
//                        return View("LoginInvalido");
                        return(RedirectToAction("Index", "Menu"));
                    }
                }
                else
                {
                    if (Url.IsLocalUrl(returnURL) && returnURL.Length > 1 && returnURL.StartsWith("/") &&
                        !returnURL.StartsWith("//") && !returnURL.StartsWith("/\\"))
                    {
                        return(View("LoginInvalido"));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Menu"));

                        //return View("LoginInvalido");
                    }
                }
            }
            return(View(usuario));
        }
Example #3
0
        public ActionResult gvpUsuarioAddNew(CE_Usuario item)
        {
            var model = db1.Usuario;

            if (ModelState.IsValid)
            {
                try
                {
                    model.Add(item);
                    db1.SaveChanges();
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_gvpUsuario", model.ToList()));
        }