public void AddContactInfo(AdditInfoModel info) { Phone ph = _unitOfWork.PhoneRepository.FindByPhone(info.Phone); AdditInfo newInfo = new AdditInfo() { PhoneId = ph.Id, Key = info.Key, Value = info.Value }; _unitOfWork.AdditInfoRepository.Add(newInfo); _unitOfWork.Save(); }
public async Task <IActionResult> NewRegister(RegisterViewModel model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { ApplicationUser user = new ApplicationUser { UserName = model.Login, Email = model.Email, PhoneNumber = model.PhoneNumber }; var result = await _unitOfWork.UserRepository.CreateAsync(user, model.Password); if (result.Succeeded) { _unitOfWork.PhoneRepository.CreateByPhone(user.PhoneNumber); _logger.LogInformation("User created a new account with password."); var code = await _unitOfWork.UserRepository.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme); await _unitOfWork.EmailSender.SendEmailConfirmationAsync(model.Email, callbackUrl); await _unitOfWork.SignInRepository.SignInAsync(user, isPersistent : false); AdditInfo addInf = new AdditInfo() { Key = "User ID", Value = model.Login, PhoneId = _unitOfWork.PhoneRepository.FindByPhone(user.PhoneNumber).Id }; _unitOfWork.AdditInfoRepository.Add(addInf); _unitOfWork.Save(); return(RedirectToLocal(returnUrl)); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }