public long AddNewUser(UserCreateEditModel modelParam) { // TODO: need refactor after changes related to Code First db ValidateDomain(modelParam.Email); var user = _mapper.Map <User>(modelParam); var entry = _userRepository.GetEntry(user); if (entry != null) { if (entry.Email == user.Email) { _actionContext.SetModelError("email", "Email is busy"); } if (entry.Phone == user.Phone) { _actionContext.SetModelError("phone", "Phone is busy"); } } _actionContext.ThrowIfModelInvalid(); user.Roles.Add(_roleRepository.GetDefault()); user.IsWaitingConfirmation = true; user = _userRepository.Add(user); _inviteService.InviteUser(user); return(user.Id); }
public ActionResult Index(string name, string email) { try { if (!string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(name)) { _inviteService.InviteUser(_appSettings, name, email); } } catch (Exception ex) { throw ex; } return(View()); }