コード例 #1
0
ファイル: HomeController.cs プロジェクト: renatomatos/prova
        public ActionResult MeusDados(Model.UsuarioModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (Web.UsuarioProxy.UsuarioServiceClient proxy = new Web.UsuarioProxy.UsuarioServiceClient())
                    {
                        proxy.Update(model);
                    }

                    return RedirectToAction("Index");
                }
            }
            catch (Exception ex)
            {
                Utils.HelperLog.WriteText(ex, "HomeController.MeusDados[POST]");
            }
            return View(model);
        }
コード例 #2
0
        public ActionResult MeusDados(Model.UsuarioModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (Web.UsuarioProxy.UsuarioServiceClient proxy = new Web.UsuarioProxy.UsuarioServiceClient())
                    {
                        proxy.Update(model);
                    }

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                Utils.HelperLog.WriteText(ex, "HomeController.MeusDados[POST]");
            }
            return(View(model));
        }
コード例 #3
0
        public ActionResult LogOn(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                using (Web.UsuarioProxy.UsuarioServiceClient proxy = new Web.UsuarioProxy.UsuarioServiceClient())
                {
                    var result = proxy.Find(model.Login);

                    if ((result != null) && (result.Length > 0))
                    {
                        if (result.First().Senha.Equals(model.Senha))
                        {
                            FormsService.SignIn(model.Login, false);
                            if (!String.IsNullOrEmpty(returnUrl))
                            {
                                return(Redirect(returnUrl));
                            }
                            else
                            {
                                return(RedirectToAction("Index", "Home"));
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("", "Senha incorreta.");
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "Usuário não encontrado.");
                    }
                }
            }

            // volta para a view
            return(View(model));
        }
コード例 #4
0
ファイル: LoginController.cs プロジェクト: renatomatos/prova
        public ActionResult LogOn(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                using (Web.UsuarioProxy.UsuarioServiceClient proxy = new Web.UsuarioProxy.UsuarioServiceClient())
                {
                    var result = proxy.Find(model.Login);

                    if ((result != null) && (result.Length > 0))
                    {
                        if (result.First().Senha.Equals(model.Senha))
                        {
                            FormsService.SignIn(model.Login, false);
                            if (!String.IsNullOrEmpty(returnUrl))
                            {
                                return Redirect(returnUrl);
                            }
                            else
                            {
                                return RedirectToAction("Index", "Home");
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("", "Senha incorreta.");
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "Usuário não encontrado.");
                    }
                }
            }

            // volta para a view
            return View(model);
        }
コード例 #5
0
ファイル: HomeController.cs プロジェクト: renatomatos/prova
        public ActionResult MeusDados()
        {
            try
            {
                using (Web.UsuarioProxy.UsuarioServiceClient proxy = new Web.UsuarioProxy.UsuarioServiceClient())
                {
                    var temp = proxy.Find(Model.SessionContextModel.UserName);

                    if (temp.Length > 0)
                    {
                        return View(temp.FirstOrDefault());
                    }
                    else
                    {
                        return RedirectToAction("Index");
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.HelperLog.WriteText(ex, "HomeController.MeusDados[GET]");
                return RedirectToAction("Index");
            }
        }
コード例 #6
0
        public ActionResult MeusDados()
        {
            try
            {
                using (Web.UsuarioProxy.UsuarioServiceClient proxy = new Web.UsuarioProxy.UsuarioServiceClient())
                {
                    var temp = proxy.Find(Model.SessionContextModel.UserName);

                    if (temp.Length > 0)
                    {
                        return(View(temp.FirstOrDefault()));
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.HelperLog.WriteText(ex, "HomeController.MeusDados[GET]");
                return(RedirectToAction("Index"));
            }
        }