예제 #1
0
        public async Task <CustomerAuthTicket> AddCustomerAccount(CustomerAccountAndAuthInfo account, Credit credit, Wishlist wishlist)
        {
            var notes = new List <string>();

            var customerAccountResource = new CustomerAccountResource(_apiContext);
            var newAccount = await customerAccountResource.AddAccountAndLoginAsync(account);

            notes.Add(string.Format("updatedby:{0},updatedDate:{1},action:{2}", newAccount.CustomerAccount.
                                    AuditInfo.UpdateBy, newAccount.CustomerAccount.AuditInfo.UpdateDate, "AddAccountAndLoginAsync"));

            var customerContactResource = new CustomerContactResource(_apiContext);

            foreach (var contact in account.Account.Contacts)
            {
                contact.AccountId = newAccount.CustomerAccount.Id;
                var newContact = await customerContactResource.AddAccountContactAsync(contact,
                                                                                      newAccount.CustomerAccount.Id);

                notes.Add(string.Format("updatedby:{0},updatedDate:{1},action:{2}", newAccount.CustomerAccount.
                                        AuditInfo.UpdateBy, newAccount.CustomerAccount.AuditInfo.UpdateDate, "AddAccountContactAsync"));
            }

            var customerCreditResource = new CreditResource(_apiContext);

            credit.CustomerId = newAccount.CustomerAccount.Id;
            var newCredit = await customerCreditResource.AddCreditAsync(credit);

            notes.Add(string.Format("updatedby:{0},updatedDate:{1},action:{2}", newAccount.CustomerAccount.
                                    AuditInfo.UpdateBy, newAccount.CustomerAccount.AuditInfo.UpdateDate, "AddCreditAsync"));


            var wishListItemResource = new WishlistResource(_apiContext);

            wishlist.CustomerAccountId = newAccount.CustomerAccount.Id;
            var newWishList = await wishListItemResource.CreateWishlistAsync(wishlist);

            notes.Add(string.Format("updatedby:{0},updatedDate:{1},action:{2}", newAccount.CustomerAccount.
                                    AuditInfo.UpdateBy, newAccount.CustomerAccount.AuditInfo.UpdateDate, "CreateWishlistAsync"));


            var customerSegmentResource =
                new Mozu.Api.Resources.Commerce.Customer.CustomerSegmentResource(_apiContext);

//            var segmentAccount = await customerSegmentResource.AddSegmentAccountsAsync()

            var customerNoteResource = new CustomerNoteResource(_apiContext);

            foreach (var note in notes)
            {
                var newNote = await customerNoteResource.AddAccountNoteAsync(
                    new CustomerNote()
                {
                    Content = note
                },
                    newAccount.CustomerAccount.Id);
            }

            return(newAccount);
        }
예제 #2
0
        public async Task <Credit> UpdateCustomerCredit(int tenantId, int?siteId,
                                                        int?masterCatalogId, Credit credit)
        {
            _apiContext = new ApiContext(tenantId, siteId, masterCatalogId);

            var customerCreditResource = new CreditResource(_apiContext);
            var updatedCustomerCredit  = await customerCreditResource.UpdateCreditAsync(credit, credit.Code);

            return(updatedCustomerCredit);
        }
예제 #3
0
        public async Task <Credit> AddCustomerCredit(Credit credit, int tenantId,
                                                     int?siteId, int?masterCatalogId)
        {
            _apiContext = new ApiContext(tenantId, siteId);

            var customerCreditResource = new CreditResource(_apiContext);
            var newCustomerCredit      = await customerCreditResource.AddCreditAsync(credit);

            return(newCustomerCredit);
        }
예제 #4
0
        public async Task <Credit> GetCustomerCredit(int tenantId, int?siteId,
                                                     int?masterCatalogId, string code)
        {
            _apiContext = new ApiContext(tenantId, siteId, masterCatalogId);

            var customerCreditResource = new CreditResource(_apiContext);
            var credit = await customerCreditResource.GetCreditAsync(code);

            return(credit);
        }
예제 #5
0
        public async Task <IEnumerable <Credit> > GetCustomerCredits(int accountId, int tenantId,
                                                                     int?siteId, int?masterCatalogId, int?startIndex, int?pageSize, string sortBy = null, string filter = null)
        {
            _apiContext = new ApiContext(tenantId, siteId, masterCatalogId);

            var customerCreditResource = new CreditResource(_apiContext);
            var credits = await customerCreditResource.GetCreditsAsync(startIndex, pageSize,
                                                                       sortBy, filter, null);

            return(credits.Items);
        }
예제 #6
0
        protected override async Task <bool> GetDataAsync()
        {
            var resource = new CreditResource(Context);

            _results = await resource.GetCreditsAsync(startIndex : StartIndex, pageSize : PageSize, sortBy : SortBy, filter : Filter, responseFields : ResponseFields);

            TotalCount = _results.TotalCount;
            PageCount  = _results.PageCount;
            PageSize   = _results.PageSize;
            return(_results.Items != null && _results.Items.Count > 0);
        }