public bool CheckUserExists(ref RegisterUserMailModel model) { foreach (var item in Persons) { if (item.EqualsEmail(model)) { model.Remember = item.Remeber; this.logger.LogInformation($"User with the mail {model.Email} already exists"); return(true); } } this.logger.LogInformation($"User with the mail {model.Email} is registered"); return(false); }
public IActionResult SignUpEmail(RegisterUserMailModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } if (model.Email == null) { this.ModelState.AddModelError("Email", "Email is requared"); } if (model.Password == null) { this.ModelState.AddModelError("Password", "Password is requared"); } if (this.ModelState.ErrorCount == 0) { if (userInfoCheckService.CheckUserExists(ref model)) { model.Exists = true; return(this.View("SignUpResult", model)); } userInfoCheckService.Persons.Add(new Person //перенести в сервис (в новый метод) { FirstName = model.FirstName, SecondName = model.SecondName, Day = model.Day, Month = model.Month, Year = model.Year, Gender = model.Gender, Email = model.Email, Password = model.Password, Remeber = model.Remember }); } return(this.View("SignUpResult", model)); }