public ActionResult MeuPerfil() { var usu = RetornaUsuario(); AlterarPerfil p = new AlterarPerfil() { Id = usu.Id, nome = usu.nick, email = usu.email, temFoto = usu.Foto != null ? true : false, pontos = usu.Pontos == null ? 0 : (int)usu.Pontos }; return(View(p)); }
public ActionResult AlterarPerfil(AlterarPerfil p) { var usu = RetornaUsuario(); usu.nick = p.nome; usu.Foto = Anexo.ArqParaByte(p.foto); db.Entry(usu).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); var identity = User.Identity as System.Security.Claims.ClaimsIdentity; identity.RemoveClaim(identity.Claims.FirstOrDefault(c => c.Type == "TemFoto")); identity.AddClaim(new Claim("TemFoto", "true")); var authenticationManager = Request.GetOwinContext().Authentication; authenticationManager.AuthenticationResponseGrant = new AuthenticationResponseGrant(new ClaimsPrincipal(identity), new AuthenticationProperties() { IsPersistent = true }); return(RedirectToAction("MeuPerfil")); }