public IActionResult Register(RegisterViewModel viewModel) { if (ModelState.IsValid) { if (_account.ExistsMobileNumber(viewModel.Mobile)) { // Go To Login } else { User user = new User() { Mobile = viewModel.Mobile, ActiveCode = CodeGenerators.ActiveCode(), Code = null, Date = pc.GetYear(DateTime.Now).ToString("0000") + "/" + pc.GetMonth(DateTime.Now).ToString("00") + "/" + pc.GetDayOfMonth(DateTime.Now).ToString("00"), FullName = null, IsActive = false, Password = HashGenerators.MD5Encoding(viewModel.Password), RoleId = _account.GetMaxRole() }; _account.AddUser(user); try { MessageSender sender = new MessageSender(); sender.SMS(viewModel.Mobile, "به فروشگاه اینترنتی خوش آمدید" + Environment.NewLine + "کد فعالسازی : " + user.ActiveCode); } catch { } return(RedirectToAction(nameof(Activate))); } } return(View(viewModel)); }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { if (!(accountManager.CheckUser(model))) { accountManager.AddUser(model); FormsAuthentication.SetAuthCookie(model.Name, true); return(RedirectToAction("Index", "Flights")); } else { ModelState.AddModelError("", "Пользователь с таким логином уже существует"); } } return(View(model)); }