Пример #1
0
        public async Task <ActionResult> ChangeEmail(ChangeEmailModel model)
        {
            if (model.NewEmail == null || model.NewEmailAgain == null)
            {
                return(View(model));
            }

            if (model.NewEmail == model.NewEmailAgain)
            {
                var account = await AccountFacade.GetAccountAccordingToEmailAsync(model.Email);

                if ((await AccountFacade.GetAccountAccordingToEmailAsync(model.NewEmail)) != null)
                {
                    ModelState.AddModelError("", "Account with this Email already exist");
                    return(View(new ChangeEmailModel {
                        Email = model.Email
                    }));
                }
                account.Email = model.NewEmail;
                var result = await AccountFacade.EditAccountAsync(account);

                return(await Login(new LoginModel { EmailAddress = model.NewEmail, Password = account.Password }, null));
            }

            ModelState.AddModelError("", "Entered Emails aren't same");
            return(View(new ChangeEmailModel {
                Email = model.Email
            }));
        }
Пример #2
0
        public async Task <ActionResult> EditAccount(AccountEditModel model)
        {
            var account = await AccountFacade.GetAccountAccordingToIdAsync(model.AccountId);

            account.FirstName         = model.FirstName;
            account.LastName          = model.LastName;
            account.Email             = model.Email;
            account.Password          = model.Password;
            account.Address           = model.Address;
            account.MobilePhoneNumber = model.MobilePhoneNumber;

            await AccountFacade.EditAccountAsync(account);

            return(RedirectToAction("AccountDetail", new { id = model.AccountId }));
        }
Пример #3
0
        public async Task <ActionResult> ChangePassword(ChangePasswordModel model)
        {
            if (model.Password == null || model.PasswordAgain == null)
            {
                return(View(model));
            }
            if (model.Password == model.PasswordAgain)
            {
                var account = await AccountFacade.GetAccountAccordingToEmailAsync(model.Email);

                account.Password = model.Password;
                var result = await AccountFacade.EditAccountAsync(account);

                return(await Login(new LoginModel { EmailAddress = model.Email, Password = model.Password }, null));
            }

            ModelState.AddModelError("", "Entered Passwords aren't same");
            return(View(new ChangePasswordModel {
                Email = model.Email
            }));
        }