protected override async Task <ICommandResult> Handle(RegisterUserWithOTPCommand command) { RegisterUserWithOTPCommandCommandResult response = new RegisterUserWithOTPCommandCommandResult(); IPDetail ipDetail = new FIL.Contracts.DataModels.IPDetail(); var user = new User(); if (command.ChannelId == Channels.Feel) { user = _userRepository.GetByEmailAndChannel(command.Email, command.ChannelId, null); } if (user == null) { var country = _countryRepository.GetByAltId(new Guid(command.PhoneCode.Split("~")[1])); var userModel = new User { AltId = Guid.NewGuid(), Email = command.Email, Password = command.PasswordHash, RolesId = command.ChannelId == Channels.Feel ? 11 : 2, CreatedBy = command.ModifiedBy, CreatedUtc = DateTime.UtcNow, UserName = command.UserName, FirstName = command.FirstName, LastName = command.LastName, PhoneCode = command.PhoneCode.Split("~")[0], PhoneNumber = command.PhoneNumber, ChannelId = command.ChannelId, SignUpMethodId = command.SignUpMethodId, IsEnabled = true, CountryId = country.Id }; userModel.IPDetailId = userModel.IPDetailId == 0 ? null : userModel.IPDetailId; userModel = _userRepository.Save(userModel); response.Success = true; response.User = userModel; try { if (command.ReferralId != null) { var referral = _referralRepository.GetByAltId(Guid.Parse(command.ReferralId)); if (referral != null) { userModel.ReferralId = referral.Id; } } ipDetail = _saveIPProvider.SaveIp(command.Ip); if (ipDetail != null) { userModel.IPDetailId = ipDetail.Id; _userRepository.Save(userModel); } } catch { ipDetail = null; } } else if (string.IsNullOrEmpty(user.PhoneCode) && string.IsNullOrEmpty(user.PhoneNumber)) { user.PhoneConfirmed = true; user.PhoneCode = command.PhoneCode; user.PhoneNumber = command.PhoneNumber; user = _userRepository.Save(user); response.Success = true; response.User = user; } else { response.EmailAlreadyRegistered = true; } return(response); }
protected override async Task Handle(RegisterUserCommand command) { IPDetail ipDetail = new FIL.Contracts.DataModels.IPDetail(); var country = _countryRepository.GetByAltId(new Guid(command.PhoneCode.Split("~")[1])); var user = new FIL.Contracts.DataModels.User { AltId = Guid.NewGuid(), Email = command.Email, Password = command.PasswordHash, RolesId = command.ChannelId == Channels.Feel ? 11 : 2, // TODO: XXX: Need a default CreatedBy = command.ModifiedBy, CreatedUtc = DateTime.UtcNow, UserName = command.UserName, FirstName = command.FirstName, LastName = command.LastName, PhoneCode = command.PhoneCode.Split("~")[0], PhoneNumber = command.PhoneNumber, ChannelId = command.ChannelId, SignUpMethodId = command.SignUpMethodId, IsEnabled = true, IsRASVMailOPT = command.IsMailOpt, CountryId = country.Id }; user.IPDetailId = user.IPDetailId == 0 ? null : user.IPDetailId; var userDetails = _userRepository.Save(user); if (command.ChannelId == Channels.Feel) { var feelUserAdditional = new FeelUserAdditionalDetail { UserId = Convert.ToInt32(userDetails.Id), OptedForMailer = Convert.ToBoolean(command.IsMailOpt), SocialLoginId = null, SignUpMethodId = Convert.ToInt32(command.SignUpMethodId), IsEnabled = true }; _feelUserAdditionalDetailRepository.Save(feelUserAdditional); } try { if (command.ReferralId != null) { var referral = _referralRepository.GetByAltId(Guid.Parse(command.ReferralId)); if (referral != null) { userDetails.ReferralId = referral.Id; } } ipDetail = _saveIPProvider.SaveIp(command.Ip); if (ipDetail != null) { userDetails.IPDetailId = ipDetail.Id; _userRepository.Save(userDetails); } } catch { ipDetail = null; } if (command.SiteId == Site.RASVSite) { await _mediator.Publish(new Events.Event.HubSpot.VisitorInfoEvent(user)); } }
protected override async Task Handle(RasvRegisterUserCommand command) { IPDetail ipDetail = new FIL.Contracts.DataModels.IPDetail(); bool shouldInsert = true; //For Facebook login in FAP if (command.ChannelId == Channels.Feel && !string.IsNullOrEmpty(command.SocialLoginId)) { var userModel = _userRepository.GetByEmailAndChannel(command.Email, command.ChannelId, command.SignUpMethodId); if (userModel != null) { shouldInsert = false; userModel.SocialLoginId = command.SocialLoginId; _userRepository.Save(userModel); } } if (shouldInsert) { var user = new User { AltId = Guid.NewGuid(), Email = command.Email, Password = command.PasswordHash, RolesId = command.ChannelId == Channels.Feel ? 11 : 2, // TODO: XXX: Need a default CreatedBy = command.ModifiedBy, CreatedUtc = DateTime.UtcNow, UserName = command.UserName, FirstName = command.FirstName, LastName = command.LastName, PhoneCode = command.PhoneCode, PhoneNumber = command.PhoneNumber, ChannelId = command.ChannelId, IsActivated = true, SignUpMethodId = command.SignUpMethodId, SocialLoginId = command.SocialLoginId, IsEnabled = true }; user.IPDetailId = user.IPDetailId == 0 ? null : user.IPDetailId; if (command.ReferralId != null) { var referral = _referralRepository.GetBySlug(command.ReferralId); if (referral != null) { user.ReferralId = referral.Id; } } var userDetails = _userRepository.Save(user); try { ipDetail = _saveIPProvider.SaveIp(command.Ip); if (ipDetail != null) { userDetails.IPDetailId = ipDetail.Id; _userRepository.Save(userDetails); } } catch { ipDetail = null; } if (command.SiteId == Site.RASVSite) { await _mediator.Publish(new VisitorInfoEvent(user)); } } }