Ejemplo n.º 1
0
 public object Post(CustomerUpdate request)
 {
     if (request.Customer.ID>0)
     {
         Db.Update(request.Customer);
     }
     else
     {
         request.Customer.ID= (int)Db.Insert(request.Customer, true);
     }
     return request.Customer.ID;
 }
Ejemplo n.º 2
0
        public async Task <CustomerView> CustomerUpdate(CustomerUpdate update)
        {
            try
            {
                string json = "";

                var client = new HttpClient();

                using (var ms = new MemoryStream())
                {
                    var serializer = new DataContractJsonSerializer(typeof(CustomerUpdate), new DataContractJsonSerializerSettings()
                    {
                        DateTimeFormat = new DateTimeFormat("yyyy-MM-dd'T'HH:mm:ss")
                    });
                    serializer.WriteObject(ms, update);
                    ms.Position = 0;
                    StreamReader sr = new StreamReader(ms);
                    json = sr.ReadToEnd();
                }

                var stream = await client.PutAsync($"http://localhost:44443/api/customer/{update.CustomerId}", new StringContent(json, Encoding.UTF8, "application/json"));

                using (var ms = new MemoryStream())
                {
                    var serializer = new DataContractJsonSerializer(typeof(CustomerView));
                    await stream.Content.CopyToAsync(ms);

                    ms.Position = 0;
                    var view = serializer.ReadObject(ms) as CustomerView;
                    return(view);
                }
            }
            catch (Exception e)
            {
                LogFactory.GetLogger().Log(LogLevel.Error, e);
                return(null);
            }
        }
        public async Task <data.Customer> Update(data.InvoiceContext db, CustomerUpdate update)
        {
            try
            {
                var customerToUpdate = await db.Customers.FirstOrDefaultAsync(w => w.CustomerId == update.CustomerId);

                customerToUpdate.Active              = update.Active;
                customerToUpdate.Address             = update.Address;
                customerToUpdate.CustomerExteranlRef = update.CustomerExteranlRef;
                customerToUpdate.CustomerId          = update.CustomerId;
                customerToUpdate.EmailAddress        = update.EmailAddress;
                customerToUpdate.IsCompany           = update.IsCompany;
                customerToUpdate.Name        = update.Name;
                customerToUpdate.PhoneNumber = update.PhoneNumber;
                customerToUpdate.TaxNo       = update.TaxNo;
                return(customerToUpdate);
            }
            catch (Exception e)
            {
                LogFactory.GetLogger().Log(LogLevel.Error, e);
                return(null);
            }
        }
Ejemplo n.º 4
0
 private static void GetandUpdateCustomer()
 {
     using (var proxy = new CustomerServiceClient())
     {
         //retrieve customer names and ids
         var custList = proxy.GetCustomerPickList();
         //select a customer and call GetCustomer
         int randomCustomerId = custList[7].Id;
         var customer         = proxy.GetCustomer(randomCustomerId);
         //make a modification to teh customer
         customer.Notes += ", new notes";
         //retrieve trips to build a new reservation
         List <Trip> trips = proxy.GetUpcomingTrips();
         //create a new reservation Reservation newRes = new Reservation();
         var newRes = new Reservation();
         //emulate selection of trip from list of trips
         newRes.Trip = trips[8];
         //create a default value for binary field
         newRes.RowVersion      = System.Text.Encoding.Default.GetBytes("0x123");
         newRes.ReservationDate = DateTime.Now;
         //if Reservations is null, instantiate it
         if (customer.Reservations == null)
         {
             customer.Reservations = new List <Reservation>();
         }
         else
         {
             customer.Reservations.Clear();
         }
         customer.Reservations.Add(newRes);
         newRes.ContactID = customer.ContactID;
         var custEdit = new CustomerUpdate {
             Customer = customer, ReservationsToDelete = null
         };
         string status = proxy.UpdateCustomer(custEdit);
     }
 }
Ejemplo n.º 5
0
        public void GetXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <update>
        <CUSTOMER>
            <CUSTOMERID>C1234</CUSTOMERID>
            <DISPLAYCONTACT />
        </CUSTOMER>
    </update>
</function>";

            Stream            stream      = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings();

            xmlSettings.Encoding    = Encoding.UTF8;
            xmlSettings.Indent      = true;
            xmlSettings.IndentChars = "    ";

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            CustomerUpdate record = new CustomerUpdate("unittest");

            record.CustomerId = "C1234";

            record.WriteXml(ref xml);

            xml.Flush();
            stream.Position = 0;
            StreamReader reader = new StreamReader(stream);

            Diff xmlDiff = DiffBuilder.Compare(expected).WithTest(reader.ReadToEnd())
                           .WithDifferenceEvaluator(DifferenceEvaluators.Default)
                           .Build();

            Assert.IsFalse(xmlDiff.HasDifferences(), xmlDiff.ToString());
        }
Ejemplo n.º 6
0
        public async Task <int> UpdateCustomerEdit(string userName, Customer customer)
        {
            if (customer.Id < 1)
            {
                return(-1);
            }
            else
            {
                using (HttpClientHandler httpClientHandler = new HttpClientHandler()) {
                    httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return(true); };
                    httpClientHandler.UseDefaultCredentials = true;

                    using (HttpClient client = new HttpClient(httpClientHandler)) {
                        client.BaseAddress = new Uri(GetWebServiceUrl("/webapplication/servicecenter/setcustomeredit"));

                        CustomerUpdate customerUpdate = new CustomerUpdate(customer)
                        {
                            UserName = userName
                        };

                        var response = await client.PostAsJsonAsync("", customerUpdate).ConfigureAwait(false);

                        int result = await response.Content.ReadAsAsync <int>().ConfigureAwait(false);

                        if (response.IsSuccessStatusCode)
                        {
                            return(result);
                        }
                        else
                        {
                            return(0);
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
 protected void UpdateCustomer(AdventureWorksEntities ctx, SalesOrder obj, CustomerUpdate _data)
 {
     obj.CustomerIdObject = ctx.Customer.Find(_data.CustomerId);
     if (obj.CustomerIdObject == null)
     {
         ErrorList.Current.AddError("Cannot find Customer with ID {0}.", _data.CustomerId);
     }
     if (_data.BillingAddress != null)
     {
         obj.BillToAddressIdObject = ctx.Address.Find(_data.BillingAddress.AddressId);
         if (obj.BillToAddressIdObject == null)
         {
             ErrorList.Current.AddError("Cannot find Address with ID {0}.", _data.BillingAddress.AddressId);
         }
     }
     if (_data.ShippingAddress != null)
     {
         obj.ShipToAddressIdObject = ctx.Address.Find(_data.ShippingAddress.AddressId);
         if (obj.ShipToAddressIdObject == null)
         {
             ErrorList.Current.AddError("Cannot find Address with ID {0}.", _data.ShippingAddress.AddressId);
         }
     }
 }
        public ActionResult Update(int id, CustomerUpdate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.CustomerId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreateCustomerService();

            if (service.UpdateCustomer(model))
            {
                TempData["SaveResult"] = "The customer has been updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Could not update the customer.");
            return(View(model));
        }
Ejemplo n.º 9
0
        public static void SendOrdersToRiskifiedExample()
        {
            #region preprocessing and loading config

            string domain    = ConfigurationManager.AppSettings["MerchantDomain"];
            string authToken = ConfigurationManager.AppSettings["MerchantAuthenticationToken"];
            RiskifiedEnvironment riskifiedEnv = (RiskifiedEnvironment)Enum.Parse(typeof(RiskifiedEnvironment), ConfigurationManager.AppSettings["RiskifiedEnvironment"]);

            // Generating a random starting order number
            // we need to send the order with a new order number in order to create it on riskified
            var rand     = new Random();
            int orderNum = rand.Next(1000, 200000);

            // Make orderNum a string to use as customer id
            string idString = $"customerId_{orderNum.ToString()}";

            #endregion

            #region order object creation

            // generate a new order - the sample generates a fixed order with same details but different order number each time
            // see GenerateOrder for more info on how to create the Order objects
            var order = GenerateOrder(orderNum);

            #endregion

            #region sending data to riskified

            // read action from console
            const string menu = "Commands:\n" +
                                "'p' for checkout\n" +
                                "'e' for checkout denied\n" +
                                "'c' for create\n" +
                                "'u' for update\n" +
                                "'s' for submit\n" +
                                "'d' for cancel\n" +
                                "'r' for partial refund\n" +
                                "'f' for fulfill\n" +
                                "'x' for decision\n" +
                                "'h' for historical sending\n" +
                                "'y' for chargeback submission\n" +
                                "'v' for decide (sync only)\n" +
                                "'l' for eligible for Deco payment \n" +
                                "'o' for opt-in to Deco payment \n" +
                                "'account' for account actions menu\n" +
                                "'q' to quit";

            const string accountActionsMenu = "Account Action Commands:\n" +
                                              "'li' for login(account)\n" +
                                              "'cc' for customer create (account)\n" +
                                              "'cu' for customer update (account)\n" +
                                              "'lo' for logout (account)\n" +
                                              "'pw' for password reset (account)\n" +
                                              "'wl' for wishlist (account)\n" +
                                              "'re' for redeem (account)\n" +
                                              "'co' for contact (account)\n" +
                                              "'menu' for main menu\n" +
                                              "'q' to quit";

            Console.WriteLine(menu);
            string commandStr = Console.ReadLine();


            // loop on console actions
            while (commandStr != null && (!commandStr.Equals("q")))
            {
                // the OrdersGateway is responsible for sending orders to Riskified servers
                OrdersGateway gateway = new OrdersGateway(riskifiedEnv, authToken, domain);
                try
                {
                    OrderNotification         res    = null;
                    AccountActionNotification accRes = null;
                    switch (commandStr)
                    {
                    case "menu":
                    case "account":
                        break;

                    case "p":
                        Console.WriteLine("Order checkout Generated with merchant order number: " + orderNum);
                        var orderCheckout = GenerateOrderCheckout(orderNum.ToString());
                        orderCheckout.Id = orderNum.ToString();

                        // sending order checkout for creation (if new orderNum) or update (if existing orderNum)
                        res = gateway.Checkout(orderCheckout);
                        break;

                    case "a":
                        Console.WriteLine("Order Advise Generated with merchant order number: " + orderNum);
                        var orderAdviseCheckout = GenerateAdviseOrderCheckout(orderNum.ToString());
                        orderAdviseCheckout.Id = orderNum.ToString();

                        // sending order checkout for creation (if new orderNum) or update (if existing orderNum)
                        res = gateway.Advise(orderAdviseCheckout);
                        break;

                    case "e":
                        Console.WriteLine("Order checkout Generated.");
                        var orderCheckoutDenied = GenerateOrderCheckoutDenied(orderNum);

                        Console.Write("checkout to deny id: ");
                        string orderCheckoutDeniedId = Console.ReadLine();

                        orderCheckoutDenied.Id = orderCheckoutDeniedId;

                        // sending order checkout for creation (if new orderNum) or update (if existing orderNum)
                        res = gateway.CheckoutDenied(orderCheckoutDenied);
                        break;

                    case "c":
                        Console.WriteLine("Order Generated with merchant order number: " + orderNum);
                        order.Id = orderNum.ToString();
                        orderNum++;
                        // sending order for creation (if new orderNum) or update (if existing orderNum)
                        res = gateway.Create(order);
                        break;

                    case "s":
                        Console.WriteLine("Order Generated with merchant order number: " + orderNum);
                        order.Id = orderNum.ToString();
                        orderNum++;
                        // sending order for submitting and analysis
                        // it will generate a callback to the notification webhook (if defined) with a decision regarding the order
                        res = gateway.Submit(order);
                        break;

                    case "v":
                        Console.WriteLine("Order Generated with merchant order number: " + orderNum);
                        order.Id = orderNum.ToString();
                        orderNum++;
                        // sending order for synchronous decision
                        // it will generate a synchronous response with the decision regarding the order
                        // (for sync flow only)
                        res = gateway.Decide(order);
                        break;

                    case "u":
                        Console.Write("Updated order id: ");
                        string upOrderId = Console.ReadLine();
                        order.Id = int.Parse(upOrderId).ToString();
                        res      = gateway.Update(order);
                        break;

                    case "d":
                        Console.Write("Cancelled order id: ");
                        string canOrderId = Console.ReadLine();
                        res = gateway.Cancel(
                            new OrderCancellation(
                                merchantOrderId: int.Parse(canOrderId),
                                cancelledAt: DateTime.Now,
                                cancelReason: "Customer cancelled before shipping"));
                        break;

                    case "r":
                        Console.Write("Refunded order id: ");
                        string refOrderId = Console.ReadLine();
                        res = gateway.PartlyRefund(
                            new OrderPartialRefund(
                                merchantOrderId: int.Parse(refOrderId),
                                partialRefunds: new[]
                        {
                            new PartialRefundDetails(
                                refundId: "12345",
                                refundedAt: DateTime.Now,              // make sure to initialize DateTime with the correct timezone
                                amount: 5.3,
                                currency: "USD",
                                reason: "Customer partly refunded on shipping fees")
                        }));
                        break;

                    case "f":
                        Console.Write("Fulfill order id: ");
                        string           fulfillOrderId   = Console.ReadLine();
                        OrderFulfillment orderFulfillment = GenerateFulfillment(int.Parse(fulfillOrderId));
                        res = gateway.Fulfill(orderFulfillment);

                        break;

                    case "x":
                        Console.Write("Decision order id: ");
                        string        decisionOrderId = Console.ReadLine();
                        OrderDecision orderDecision   = GenerateDecision(int.Parse(decisionOrderId));
                        res = gateway.Decision(orderDecision);

                        break;

                    case "h":
                        int startOrderNum     = orderNum;
                        var orders            = new List <Order>();
                        var financialStatuses = new[] { "paid", "cancelled", "chargeback" };
                        for (int i = 0; i < 22; i++)
                        {
                            Order o = GenerateOrder(orderNum++);
                            o.FinancialStatus = financialStatuses[i % 3];
                            orders.Add(o);
                        }
                        Console.WriteLine("Orders Generated with merchant order numbers: {0} to {1}", startOrderNum, orderNum - 1);
                        // sending 3 historical orders with different processing state
                        Dictionary <string, string> errors;
                        bool success = gateway.SendHistoricalOrders(orders, out errors);
                        if (success)
                        {
                            Console.WriteLine("All historical orders sent successfully");
                        }
                        else
                        {
                            Console.WriteLine("Some historical orders failed to send:");
                            Console.WriteLine(String.Join("\n", errors.Select(p => p.Key + ":" + p.Value).ToArray()));
                        }
                        break;

                    case "y":
                        Console.Write("Chargeback order id: ");
                        string          chargebackOrderId = Console.ReadLine();
                        OrderChargeback orderChargeback   = GenerateOrderChargeback(chargebackOrderId);
                        res = gateway.Chargeback(orderChargeback);

                        break;

                    case "l":
                        Console.Write("Check Deco eligibility on id: ");
                        string      eligibleOrderId     = Console.ReadLine();
                        OrderIdOnly eligibleOrderIdOnly = GenerateOrderIdOnly(eligibleOrderId);
                        res = gateway.Eligible(eligibleOrderIdOnly);

                        break;

                    case "o":
                        Console.Write("Opt-in to Deco payment on id: ");
                        string      optInOrderId     = Console.ReadLine();
                        OrderIdOnly optInOrderIdOnly = GenerateOrderIdOnly(optInOrderId);
                        res = gateway.OptIn(optInOrderIdOnly);

                        break;

                    case "li":
                        Console.Write("Login account action");
                        Login login = GenerateLogin(idString);

                        accRes = gateway.Login(login);
                        break;

                    case "cc":
                        Console.Write("Customer Create account action");
                        CustomerCreate customerCreate = GenerateCustomerCreate(idString);

                        accRes = gateway.CustomerCreate(customerCreate);
                        break;

                    case "cu":
                        Console.Write("Customer Update account action");
                        CustomerUpdate customerUpdate = GenerateCustomerUpdate(idString);

                        accRes = gateway.CustomerUpdate(customerUpdate);
                        break;

                    case "lo":
                        Console.Write("Logout account action");
                        Logout logout = GenerateLogout(idString);

                        accRes = gateway.Logout(logout);
                        break;

                    case "pw":
                        Console.Write("ResetPasswordRequest account action");
                        ResetPasswordRequest resetPasswordRequest = GenerateResetPasswordRequest(idString);

                        accRes = gateway.ResetPasswordRequest(resetPasswordRequest);
                        break;

                    case "wl":
                        Console.Write("WishlistChanges account action");
                        WishlistChanges wishlistChanges = GenerateWishlistChanges(idString);

                        accRes = gateway.WishlistChanges(wishlistChanges);
                        break;

                    case "re":
                        Console.Write("Redeem account action");
                        Redeem redeem = GenerateRedeem(idString);

                        accRes = gateway.Redeem(redeem);
                        break;

                    case "co":
                        Console.Write("Customer Reach-Out account action");
                        CustomerReachOut customerReachOut = GenerateCustomerReachOut(idString);

                        accRes = gateway.CustomerReachOut(customerReachOut);
                        break;
                    }


                    if (res != null)
                    {
                        Console.WriteLine("\n\nOrder sent successfully:" +
                                          "\nStatus at Riskified: " + res.Status +
                                          "\nOrder ID received:" + res.Id +
                                          "\nDescription: " + res.Description +
                                          "\nWarnings: " + (res.Warnings == null ? "---" : string.Join("        \n", res.Warnings)) + "\n\n");
                    }
                    if (accRes != null)
                    {
                        Console.WriteLine("\n\nAccount Action sent successfully:" +
                                          "\nDecision: " + accRes.Decision);
                    }
                }
                catch (OrderFieldBadFormatException e)
                {
                    // catching
                    Console.WriteLine("Exception thrown on order field validation: " + e.Message);
                }
                catch (RiskifiedTransactionException e)
                {
                    Console.WriteLine("Exception thrown on transaction: " + e.Message);
                }

                // ask for next action to perform
                Console.WriteLine();
                if (commandStr.Equals("account"))
                {
                    Console.WriteLine(accountActionsMenu);
                }
                else
                {
                    Console.WriteLine(menu);
                }
                commandStr = Console.ReadLine();
            }

            #endregion
        }
Ejemplo n.º 10
0
        public void GetAllXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <update>
        <CUSTOMER>
            <CUSTOMERID>C1234</CUSTOMERID>
            <NAME>Intacct Corp</NAME>
            <DISPLAYCONTACT>
                <PRINTAS>Intacct Corporation</PRINTAS>
                <COMPANYNAME>Intacct Corp.</COMPANYNAME>
                <TAXABLE>true</TAXABLE>
                <TAXGROUP>CA</TAXGROUP>
                <PREFIX>Mr</PREFIX>
                <FIRSTNAME>Bill</FIRSTNAME>
                <LASTNAME>Smith</LASTNAME>
                <INITIAL>G</INITIAL>
                <PHONE1>12</PHONE1>
                <PHONE2>34</PHONE2>
                <CELLPHONE>56</CELLPHONE>
                <PAGER>78</PAGER>
                <FAX>90</FAX>
                <EMAIL1>[email protected]</EMAIL1>
                <EMAIL2>[email protected]</EMAIL2>
                <URL1>www.intacct.com</URL1>
                <URL2>us.intacct.com</URL2>
                <MAILADDRESS>
                    <ADDRESS1>300 Park Ave</ADDRESS1>
                    <ADDRESS2>Ste 1400</ADDRESS2>
                    <CITY>San Jose</CITY>
                    <STATE>CA</STATE>
                    <ZIP>95110</ZIP>
                    <COUNTRY>United States</COUNTRY>
                </MAILADDRESS>
            </DISPLAYCONTACT>
            <ONETIME>false</ONETIME>
            <STATUS>active</STATUS>
            <HIDEDISPLAYCONTACT>false</HIDEDISPLAYCONTACT>
            <CUSTTYPE>SaaS</CUSTTYPE>
            <PARENTID>C5678</PARENTID>
            <GLGROUP>Group</GLGROUP>
            <TERRITORYID>NE</TERRITORYID>
            <SUPDOCID>A1234</SUPDOCID>
            <TERMNAME>N30</TERMNAME>
            <OFFSETGLACCOUNTNO>1200</OFFSETGLACCOUNTNO>
            <ARACCOUNT>4000</ARACCOUNT>
            <SHIPPINGMETHOD>USPS</SHIPPINGMETHOD>
            <RESALENO>123</RESALENO>
            <TAXID>12-3456789</TAXID>
            <CREDITLIMIT>1234.56</CREDITLIMIT>
            <ONHOLD>false</ONHOLD>
            <DELIVERYOPTIONS>Print#~#E-Mail</DELIVERYOPTIONS>
            <CUSTMESSAGEID>hello</CUSTMESSAGEID>
            <COMMENTS>my comment</COMMENTS>
            <CURRENCY>USD</CURRENCY>
            <ARINVOICEPRINTTEMPLATEID>temp1</ARINVOICEPRINTTEMPLATEID>
            <OEQUOTEPRINTTEMPLATEID>temp2</OEQUOTEPRINTTEMPLATEID>
            <OEORDERPRINTTEMPLATEID>temp3</OEORDERPRINTTEMPLATEID>
            <OELISTPRINTTEMPLATEID>temp4</OELISTPRINTTEMPLATEID>
            <OEINVOICEPRINTTEMPLATEID>temp5</OEINVOICEPRINTTEMPLATEID>
            <OEADJPRINTTEMPLATEID>temp6</OEADJPRINTTEMPLATEID>
            <OEOTHERPRINTTEMPLATEID>temp7</OEOTHERPRINTTEMPLATEID>
            <CONTACTINFO>
                <CONTACTNAME>primary</CONTACTNAME>
            </CONTACTINFO>
            <BILLTO>
                <CONTACTNAME>bill to</CONTACTNAME>
            </BILLTO>
            <SHIPTO>
                <CONTACTNAME>ship to</CONTACTNAME>
            </SHIPTO>
            <OBJECTRESTRICTION>Restricted</OBJECTRESTRICTION>
            <RESTRICTEDLOCATIONS>100#~#200</RESTRICTEDLOCATIONS>
            <RESTRICTEDDEPARTMENTS>D100#~#D200</RESTRICTEDDEPARTMENTS>
            <CUSTOMFIELD1>Hello</CUSTOMFIELD1>
        </CUSTOMER>
    </update>
</function>";

            CustomerUpdate record = new CustomerUpdate("unittest")
            {
                CustomerId            = "C1234",
                CustomerName          = "Intacct Corp",
                PrintAs               = "Intacct Corporation",
                CompanyName           = "Intacct Corp.",
                Taxable               = true,
                TaxId                 = "12-3456789",
                ContactTaxGroupName   = "CA",
                Prefix                = "Mr",
                FirstName             = "Bill",
                LastName              = "Smith",
                MiddleName            = "G",
                PrimaryPhoneNo        = "12",
                SecondaryPhoneNo      = "34",
                CellularPhoneNo       = "56",
                PagerNo               = "78",
                FaxNo                 = "90",
                PrimaryEmailAddress   = "*****@*****.**",
                SecondaryEmailAddress = "*****@*****.**",
                PrimaryUrl            = "www.intacct.com",
                SecondaryUrl          = "us.intacct.com",
                AddressLine1          = "300 Park Ave",
                AddressLine2          = "Ste 1400",
                City                                = "San Jose",
                StateProvince                       = "CA",
                ZipPostalCode                       = "95110",
                Country                             = "United States",
                OneTime                             = false,
                Active                              = true,
                ExcludedFromContactList             = false,
                CustomerTypeId                      = "SaaS",
                ParentCustomerId                    = "C5678",
                GlGroupName                         = "Group",
                TerritoryId                         = "NE",
                AttachmentsId                       = "A1234",
                PaymentTerm                         = "N30",
                OffsetArGlAccountNo                 = "1200",
                DefaultRevenueGlAccountNo           = "4000",
                ShippingMethod                      = "USPS",
                ResaleNumber                        = "123",
                CreditLimit                         = 1234.56M,
                OnHold                              = false,
                DeliveryMethod                      = "Print#~#E-Mail",
                DefaultInvoiceMessage               = "hello",
                Comments                            = "my comment",
                DefaultCurrency                     = "USD",
                PrintOptionArInvoiceTemplateName    = "temp1",
                PrintOptionOeQuoteTemplateName      = "temp2",
                PrintOptionOeOrderTemplateName      = "temp3",
                PrintOptionOeListTemplateName       = "temp4",
                PrintOptionOeInvoiceTemplateName    = "temp5",
                PrintOptionOeAdjustmentTemplateName = "temp6",
                PrintOptionOeOtherTemplateName      = "temp7",
                PrimaryContactName                  = "primary",
                BillToContactName                   = "bill to",
                ShipToContactName                   = "ship to",
                RestrictionType                     = "Restricted",
                RestrictedLocations                 = new List <string>()
                {
                    "100",
                    "200",
                },
                RestrictedDepartments = new List <string>()
                {
                    "D100",
                    "D200",
                },
                CustomFields = new Dictionary <string, dynamic>
                {
                    { "CUSTOMFIELD1", "Hello" }
                }
            };

            this.CompareXml(expected, record);
        }
Ejemplo n.º 11
0
 public IHttpActionResult Update(int id, CustomerUpdate customer)
 {
     customer.Id = id;
     _customerService.Update(customer);
     return(Ok());
 }
Ejemplo n.º 12
0
        private void SyncCustomers()
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                //Check if all fields are filled.
                if ((StoreIDtextBox.Text == "") || (PasswordTextBox.Text == ""))
                {
                    RewardsErrorLabel.Text = "Store ID or Password are empty";
                    return;
                }

                CustomerUpdate newUpdate = new CustomerUpdate();
                newUpdate.store_id = Convert.ToInt32(StoreIDtextBox.Text);
                newUpdate.password = PasswordTextBox.Text;

                switch (Properties.Settings.Default.POSSoftware)
                {
                    case "MYOB":
                        newUpdate.customerList = MYOBRewards.GetRecentlyModifiedCustomers().ToArray();
                        break;
                    case "Microsoft":
                        if(TestSQLConnection(MicrosoftLocationTextBox.Text, MicrosoftDBTextBox.Text, MicrosoftUserTextBox.Text, MicrosoftPasswordTextBox.Text))
                        {
                            newUpdate.customerList = MicrosoftRewards.GetRecentlyModifiedCustomers().ToArray();
                        }
                        break;
                }

                if (newUpdate.customerList.Count() == 0)
                {
                         AddLog("No customers need to be updated.", false);
                }
                else
                {
                    AdProvider provider = new AdProvider();
                         provider.Url = WebServiceTextBox.Text;
                         provider.Timeout = 100000000;
                    CustomerUpdateResponse newResponse = provider.UpdateCustomers(newUpdate);

                    if (newResponse.is_error)
                    {
                        AddLog(newResponse.status,true);
                        RewardsErrorLabel.Text = newResponse.status;
                    }
                    else
                    {
                        RewardsErrorLabel.Text = newResponse.status;
                        foreach (string item in newResponse.responses)
                        {
                            string entry = item;
                            lbLog.AppendText(entry + "\r\n");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                AddLog(ex.ToString(),true);
                RewardsErrorLabel.Text = "An error has occurred.Check the log to the left.";
            }

               Cursor.Current = Cursors.Default;
        }
 public AccountActionNotification CustomerUpdate(CustomerUpdate customerUpdate)
 {
     return(SendAccountAction(customerUpdate, HttpUtils.BuildUrl(_env, "/customers/customer_update", FlowStrategy.Account)));
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Synchronizes a set of customers using a connected IntacctClient
        /// </summary>
        /// <param name="client">The Client to sync to</param>
        /// <param name="orgcustomers">Customer Data to Send</param>
        private async Task SyncOrgCustomers(OnlineClient client, IEnumerable <IntacctCustomer> orgcustomers, PerformContext context)
        {
            IList <string> types = await GetCustTypes(client, context);

            IDictionary <string, string> customermap = await GetCustomerIds(client, context);

            // Filter Existing Out
            if (SyncOnlyNew)
            {
                context.WriteLine("Filtering out Existing Customers");
                orgcustomers = orgcustomers.Where(c => !customermap.ContainsKey(c.CUSTOMERID)).ToArray();
            }

            // Send in batches of Customers
            int sent  = 0;
            int total = orgcustomers.Count();

            while (sent < total)
            {
                // What's in this batch
                var batchData = orgcustomers.Skip(sent).Take(100).ToList();
                context.WriteLine("Preparing Batch of 100 ({0} - {1} of {2})", sent, sent + batchData.Count, total);
                sent += batchData.Count;

                // Create the Batch for Intacct
                List <IFunction> batchFunctions = new List <IFunction>();
                foreach (var customer in batchData)
                {
                    var hasValidCustType = types.Contains(customer.CUSTTYPENAME);
                    if (customermap.ContainsKey(customer.CUSTOMERID))
                    {
                        // Update the Customer
                        CustomerUpdate update = new CustomerUpdate
                        {
                            CustomerId          = customer.CUSTOMERID,
                            CustomerName        = IntacctCleanString(customer.CUSTNAME),
                            PrintAs             = customer.CONTACTNAME,
                            FirstName           = customer.FIRSTNAME,
                            LastName            = customer.LASTNAME,
                            PrimaryEmailAddress = customer.EMAIL1,
                            Active           = customer.STATUS == "active",
                            AddressLine1     = customer.ADDRESS1,
                            City             = customer.CITY,
                            StateProvince    = customer.STATE,
                            Country          = "United States",
                            ZipPostalCode    = customer.ZIP,
                            ParentCustomerId = customer.PARENTID
                        };
                        if (!String.IsNullOrWhiteSpace(customer.FIRSTNAME))
                        {
                            update.FirstName = customer.FIRSTNAME;
                        }
                        if (!String.IsNullOrWhiteSpace(customer.LASTNAME))
                        {
                            update.LastName = customer.LASTNAME;
                        }
                        update.CustomFields.Add("RECORDNO", customermap[customer.CUSTOMERID]);
                        if (hasValidCustType)
                        {
                            update.CustomerTypeId = customer.CUSTTYPENAME;
                        }
                        batchFunctions.Add(update);
                    }
                    else
                    {
                        // Create the Customer
                        CustomerCreate create = new CustomerCreate
                        {
                            CustomerId          = customer.CUSTOMERID,
                            CustomerName        = IntacctCleanString(customer.CUSTNAME),
                            PrintAs             = customer.CONTACTNAME,
                            FirstName           = customer.FIRSTNAME,
                            LastName            = customer.LASTNAME,
                            PrimaryEmailAddress = customer.EMAIL1,
                            Active           = customer.STATUS == "active",
                            AddressLine1     = customer.ADDRESS1,
                            City             = customer.CITY,
                            StateProvince    = customer.STATE,
                            Country          = "United States",
                            ZipPostalCode    = customer.ZIP,
                            ParentCustomerId = customer.PARENTID
                        };
                        if (hasValidCustType)
                        {
                            create.CustomerTypeId = customer.CUSTTYPENAME;
                        }
                        batchFunctions.Add(create);
                    }
                }

                // Send the Batch to Intacct
                context.WriteLine("Sending Batch to Intacct");
                var response = await client.ExecuteBatch(batchFunctions);

                context.WriteLine("Inspecting Response from Intacct");
                foreach (var result in response.Results)
                {
                    if (result.Errors != null)
                    {
                        context.SetTextColor(ConsoleTextColor.Red);
                        context.WriteLine("==================================");
                        foreach (var err in result.Errors)
                        {
                            context.WriteLine(err);
                        }
                        context.WriteLine("==================================");
                        context.WriteLine();
                        Console.ResetColor();
                    }
                }
            }
        }
Ejemplo n.º 15
0
        public BaseResponse UpdateMember(string memberid,
                                         string salutation, string firstname, string lastname, string suffix,
                                         string professionaltitle, string email, bool optin, string businessname, string address1, string address2, string address3,
                                         string city, string state, string postalcode, string country,
                                         string phone, string screenname,
                                         bool debug)
        {
            methodName = "UpdateMember";

            try
            {
                #region  set member data
                Member memberData = new Member();
                memberData.MemberId          = memberid;
                memberData.Salutation        = salutation;
                memberData.FirstName         = firstname;
                memberData.LastName          = lastname;
                memberData.Suffix            = suffix;
                memberData.ProfessionalTitle = professionaltitle;
                memberData.OptIn             = optin;
                memberData.Email             = email;

                memberData.Address = new Address();
                memberData.Address.BusinessName = businessname;
                memberData.Address.Address1     = address1;
                memberData.Address.Address2     = address2;
                memberData.Address.Address3     = address3;
                memberData.Address.City         = city;
                memberData.Address.State        = state;
                memberData.Address.PostalCode   = postalcode;
                memberData.Address.Country      = country;
                memberData.Address.Phone        = phone;
                #endregion

                //TODO :  Error handling for dupe email or screenname

                #region update ah db here
                using (HarperACL.ACLDataDataContext context = new ACLDataDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
                {
                    HarperACL.Customer customer = (from a in context.Customers
                                                   join b in context.SFG_CustomerNumbers
                                                   on a.cusID equals b.cusID
                                                   where b.SFGCustNum == memberid
                                                   select a).Single();

                    int existing = (from a in context.Customers
                                    where
                                    (a.cusEmail == email || a.cusDisplayName == screenname) &&
                                    a.cusID != customer.cusID
                                    select a).Count();
                    if (existing > 0)
                    {
                        throw new Exception("Unable to update member data, screen name or email already in use.");
                    }
                    customer.cusPrefix      = salutation;
                    customer.cusFirstName   = firstname;
                    customer.cusLastName    = lastname;
                    customer.cusSuffix      = suffix;
                    customer.cusTitle       = professionaltitle;
                    customer.cusEmail       = email;
                    customer.cusCompany     = businessname;
                    customer.cusPhone1      = phone;
                    customer.cusDateUpdated = DateTime.Now;
                    customer.cusDisplayName = screenname;

                    HarperACL.AddressCustomer address = (from a in context.AddressCustomers
                                                         where a.addID == customer.addID
                                                         select a).Single();
                    address.addAddress1    = address1;
                    address.addAddress2    = address2;
                    address.addAddress3    = address3;
                    address.addCity        = city;
                    address.addCountry     = country;
                    address.addDateUpdated = DateTime.Now;
                    address.addPostalCode  = postalcode;
                    address.addRegion      = state;

                    context.SubmitChanges();
                }
                #endregion

                //update at SFG
                UpdateMemberRequest request = new UpdateMemberRequest(memberData, debug);
                baseResponse = CustomerUpdate.UpdateMember(request);
            }
            catch (Exception ex)
            {
                LogMethodError(methodName, ex);
            }

            return(baseResponse);
        }
Ejemplo n.º 16
0
        public HttpResponse <OkResponse> UpdateCustomer(string customerId, CustomerUpdate requestModel)
        {
            var updateCustomerUri = string.Format(ApiUrls.Customer, customerId);

            return(new ApiHttpClient().PutRequest <OkResponse>(updateCustomerUri, AppSettings.SecretKey, requestModel));
        }
Ejemplo n.º 17
0
        public async Task <ActionResult <Customer> > UpdateCustomer(int id, [FromBody] CustomerUpdate model)
        {
            Customer result = await customerFacade.Update(id, model);

            return(Ok(result));
        }
Ejemplo n.º 18
0
        public Task <CustomerResponse> UpdateCustomerAsync(string customerToken, CustomerUpdate customerUpdate)
        {
            var request = UpdateCustomerRequest(customerToken, customerUpdate);

            return(ExecuteAsync <CustomerResponse>(request));
        }
Ejemplo n.º 19
0
 public Customer UpdateCustomer(CustomerUpdate customer)
 {
     return(CustomerDAL.UpdateCustomer(customer));
 }
Ejemplo n.º 20
0
        public Task <HttpResponse <OkResponse> > UpdateCustomerAsync(string customerId, CustomerUpdate requestModel)
        {
            var updateCustomerUri = string.Format(_configuration.ApiUrls.Customer, customerId);

            return(_apiHttpClient.PutRequest <OkResponse>(updateCustomerUri, _configuration.SecretKey, requestModel));
        }
Ejemplo n.º 21
0
 public HttpResponse <OkResponse> UpdateCustomer(string customerId, CustomerUpdate requestModel)
 {
     return(_customerServiceAsync.UpdateCustomerAsync(customerId, requestModel).Result);
 }
Ejemplo n.º 22
0
        public static void Run(ILogger logger)
        {
            OnlineClient client = Bootstrap.Client(logger);

            logger.LogInformation("Executing CRUD customer functions to API");

            CustomerCreate create = new CustomerCreate()
            {
                CustomerName = "Joshua Granley",
                Active       = false,
            };

            Task <OnlineResponse> createTask = client.Execute(create);

            createTask.Wait();
            OnlineResponse createResponse = createTask.Result;
            Result         createResult   = createResponse.Results[0];

            string customerId = createResult.Data[0].Element("CUSTOMERID").Value;
            int    recordNo   = int.Parse(createResult.Data[0].Element("RECORDNO").Value);

            Console.WriteLine("Created inactive customer ID " + customerId);

            CustomerUpdate update = new CustomerUpdate()
            {
                CustomerId = customerId,
                Active     = true,
            };

            Task <OnlineResponse> updateTask = client.Execute(update);

            updateTask.Wait();

            Console.WriteLine("Updated customer ID " + customerId + " to active");

            Read read = new Read()
            {
                ObjectName = "CUSTOMER",
                Fields     =
                {
                    "RECORDNO",
                    "CUSTOMERID",
                    "STATUS",
                },
                Keys =
                {
                    recordNo,
                }
            };

            Task <OnlineResponse> readTask = client.Execute(read);

            readTask.Wait();

            Console.WriteLine("Read customer ID " + customerId);

            CustomerDelete delete = new CustomerDelete()
            {
                CustomerId = customerId,
            };

            Task <OnlineResponse> deleteTask = client.Execute(delete);

            deleteTask.Wait();

            Console.WriteLine("Deleted customer ID " + customerId);

            LogManager.Flush();
        }
Ejemplo n.º 23
0
        public CustomerResponse UpdateCustomer(string customerToken, CustomerUpdate customerUpdate)
        {
            var request = UpdateCustomerRequest(customerToken, customerUpdate);

            return(Execute <CustomerResponse>(request));
        }
 public HttpResponse<OkResponse> UpdateCustomer(string customerId, CustomerUpdate requestModel)
 {
     var updateCustomerUri = string.Format(ApiUrls.Customer, customerId);
     return new ApiHttpClient().PutRequest<OkResponse>(updateCustomerUri, AppSettings.SecretKey, requestModel);
 }