예제 #1
0
        public ActionResult Configuration()
        {
            var datosAgente = (from user in _db.AspNetUsers
                               where user.UserName == User.Identity.Name
                               select user).FirstOrDefault();

            var AgentConfiguration = new ConfigurationAgentCoachUsers
            {
                UserId            = datosAgente.Id,
                PhotoUser         = datosAgente.ProfilePictureLocation,
                UserName          = User.Identity.Name,
                correoCorporativo = datosAgente.Email
            };

            return(View(AgentConfiguration));
        }
예제 #2
0
        public async Task <ActionResult> Configuration(ConfigurationAgentCoachUsers model, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByIdAsync(model.UserId);

                var token = await UserManager.GeneratePasswordResetTokenAsync(model.UserId);

                if (model.Password != null)
                {
                    var result = await UserManager.ResetPasswordAsync(model.UserId, token, model.Password);

                    if (result.Succeeded)
                    {
                        var email = await UserManager.FindByEmailAsync(model.correoCorporativo);

                        if (email == null)
                        {
                            user.Email = model.correoCorporativo;
                            //Block to try and upload user profile picture (if provided)
                            var result2 = await UserManager.UpdateAsync(user);
                        }
                    }

                    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                    return(RedirectToAction("Index", "Home"));

                    TempData["Success"] = "Se ha modificado los datos correctamente.";
                    ViewBag.Message     = "Se ha modificado los datos correctamente.";

                    AddErrors(result);
                }
                else
                {
                    var email = await UserManager.FindByEmailAsync(model.correoCorporativo);

                    if (email == null)
                    {
                        user.Email = model.correoCorporativo;
                        //Block to try and upload user profile picture (if provided)
                        var result2 = await UserManager.UpdateAsync(user);
                    }
                }
            }

            return(Redirect("/Agent/Index"));
        }