public static void RegisterAccount(this IRepository<AccountProfile> repository, AccountProfile accountData, string password)
 {
     accountData.Password = Encode(password);
     repository.SaveOrUpdateAll(accountData);
 }
Exemplo n.º 2
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Попытка зарегистрировать пользователя
                try
                {
                    var account = new AccountProfile()
                    {
                        ExternalId = Guid.NewGuid(),
                        Email = model.UserName,
                        Name = model.UserName,
                        Role = Data.Enum.AccountRole.User,
                        Address = model.Address,
                        Phone = model.Phone
                    };

                    AccountRepository.RegisterAccount(account, model.Password);

                    return RedirectToAction("Login", "Account");
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", e.Message);
                }
            }

            // Появление этого сообщения означает наличие ошибки; повторное отображение формы
            return View(model);
        }