public virtual void SaveMyDetails(IViewModel viewModel) { var person = _personService.Get(_securityContextService.GetIdentityUserSystemId().GetValueOrDefault())?.MakeWritableClone(); if (person == null) { return; } person.MapFrom(viewModel); using (_securityContextService.ActAsSystem()) { _personService.Update(person); } var addressType = _addressTypeService.Get(AddressTypeNameConstants.Address); var address = person.Addresses.FirstOrDefault(x => x.AddressTypeSystemId == addressType.SystemId); //Check if user has the same country in the address as channel has. if (address != null && !address.Country.Equals(_requestModelAccessor.RequestModel.CountryModel.Country.Id, StringComparison.CurrentCultureIgnoreCase)) { var country = _countryService.Get(address.Country); // Set user's country to the channel _requestModelAccessor.RequestModel.Cart.SetChannel(_requestModelAccessor.RequestModel.ChannelModel.Channel, country, SecurityToken.CurrentSecurityToken); } _checkoutState.ClearState(); }
public virtual async Task SaveMyDetails(IViewModel viewModel, bool checkCountry = true) { var person = _personService.Get(_securityContextService.GetIdentityUserSystemId().GetValueOrDefault())?.MakeWritableClone(); if (person == null) { return; } person.MapFrom(viewModel); using (_securityContextService.ActAsSystem()) { _personService.Update(person); } if (checkCountry) { var addressType = _addressTypeService.Get(AddressTypeNameConstants.Address); var address = person.Addresses.FirstOrDefault(x => x.AddressTypeSystemId == addressType.SystemId); //Check if user has the same country in the address as channel has. if (address != null && !address.Country.Equals(_requestModelAccessor.RequestModel.CountryModel.Country.Id, StringComparison.CurrentCultureIgnoreCase)) { // Set user's country to the channel await _cartContextAccessor.CartContext.SelectCountryAsync(new SelectCountryArgs { CountryCode = address.Country }); } } _checkoutState.ClearState(); }
public override bool Login(string loginName, string password, string newPassword) { var result = _authenticationService.PasswordSignIn(loginName, password, newPassword); switch (result) { case AuthenticationResult.Success: _checkoutState.ClearState(); return(true); case AuthenticationResult.RequiresChangedPassword: throw new ChangePasswordException("You need to change password."); default: return(false); } }
public override bool Login(string loginName, string password, string newPassword, out SecurityToken token) { token = SecurityToken.AnonymousToken; var result = _authenticationService.PasswordSignIn(loginName, password, newPassword); switch (result) { case AuthenticationResult.Success: token = new SecurityToken((ClaimsIdentity)System.Threading.Thread.CurrentPrincipal.Identity); _checkoutState.ClearState(); return(true); case AuthenticationResult.RequiresChangedPassword: throw new ChangePasswordException("You need to change password."); default: return(false); } }