public List <Core.Models.Profile.Account> GetAccountsForUser(Guid userId) { // get user organization info var profileQuery = new CommerceServer.Foundation.CommerceQuery <CommerceServer.Foundation.CommerceEntity>("UserOrganizations"); profileQuery.SearchCriteria.Model.Properties["UserId"] = userId.ToCommerceServerFormat(); CommerceServer.Foundation.CommerceResponse res = Svc.Impl.Helpers.FoundationService.ExecuteRequest(profileQuery.ToRequest()); List <Account> userAccounts = new List <Account>(); foreach (CommerceEntity ent in (res.OperationResponses[0] as CommerceQueryOperationResponse).CommerceEntities) { Organization org = new Organization(ent); if (org.OrganizationType == "1") { userAccounts.Add(new Account() { Id = Guid.Parse(org.Id), Name = org.Name, }); } } return(userAccounts); }
public static CommerceResponse ExecuteRequest(CommerceRequest request) { // Execute the operation and get the results back CommerceServer.Foundation.CommerceResponse response = GetServiceAgent().ProcessRequest(CreateRequestContext(), request); return(response); }