public Result <CommerceUserModel> UpdateAccountInfo(CommerceUserModel user) { Assert.ArgumentNotNull(user, nameof(user)); var result = new Result <CommerceUserModel>(); ManagerResponse <GetUserResult, CommerceUser> getUserResponse = this.accountManager.GetUser(user.ContactId); if (!getUserResponse.ServiceProviderResult.Success || getUserResponse.Result == null) { result.SetErrors(getUserResponse.ServiceProviderResult); return(result); } CommerceUser userForUpdate = getUserResponse.Result; userForUpdate.FirstName = user.FirstName; userForUpdate.LastName = user.LastName; ManagerResponse <UpdateUserResult, CommerceUser> userUpdateResponse = this.accountManager.UpdateUser(userForUpdate); if (!userUpdateResponse.ServiceProviderResult.Success || userUpdateResponse.Result == null) { result.SetErrors(userUpdateResponse.ServiceProviderResult); return(result); } result.SetResult(this.entityMapper.MapToCommerceUserModel(userUpdateResponse.Result)); return(result); }
private void CompleteAuthentication(CommerceUserModel commerceUser) { var anonymousContact = this.visitorContext.ContactId; this.visitorContext.CurrentUser = commerceUser; this.cartRepository.MergeCarts(anonymousContact); CommerceTracker.Current.IdentifyAs("CommerceUser", commerceUser.UserName, (string)null, true); }
private CreateAccountResultModel MapToCreateAccountResultDto( bool created, string message, CommerceUser commerceUser) { CommerceUserModel accountInfo = this.entityMapper.MapToCommerceUserModel(commerceUser); return(new CreateAccountResultModel { Created = created, Message = message, AccountInfo = accountInfo }); }
public ActionResult UpdateUser(CommerceUserModel user) { try { this.trackingService.EnsureTracker(); var updateUserResult = this.accountRepository.UpdateAccountInfo(user); if (!updateUserResult.Success) { return(this.JsonError(updateUserResult.Errors.ToArray(), HttpStatusCode.BadRequest)); } return(this.JsonOk(updateUserResult.Data)); } catch (Exception ex) { return(this.JsonError(ex.Message, HttpStatusCode.InternalServerError, ex)); } }
private bool LoginUser(UserLoginModel userLogin, out CommerceUserModel commerceUser) { var userName = Membership.GetUserNameByEmail(userLogin.Email); if (string.IsNullOrWhiteSpace(userName)) { commerceUser = null; return(false); } commerceUser = this.customerProvider.GetCommerceUser(userName); if (commerceUser == null) { return(false); } return(AuthenticationManager.Login(userName, userLogin.Password)); }
protected override void DoProcessSafe(GetLayoutServiceContextArgs args, AppConfiguration application) { CommerceUserModel model = this.visitorContext.CurrentUser; args.ContextData.Add("commerceUser", model); }