Exemple #1
0
        private Unit4Customer MapUnit4Customer(Customer customer)
        {
            string name = customer.CompanyName;

            string noSpace = name.Replace(" ", "");

            string maxEight = noSpace.Substring(0, 8);

            string newShortName = maxEight.ToUpper();


            Unit4Customer unit4Customer = new Unit4Customer()
            {
                customerId = customer.CustomerID,
                city       = customer.City,
                name       = customer.CompanyName,
                email      = customer.Email,
                countryId  = customer.CountryID,
                street2    = customer.Street + " " + customer.HouseNumber + " " + customer.HouseNumberAddition,
                languageId = customer.LanguageID,
                telephone  = customer.Tel,
                zipCode    = customer.ZipCode,
                shortName  = newShortName,
                person     = customer.Salutation + " " + customer.FirstName + " " + customer.LastName
            };

            return(unit4Customer);
        }
Exemple #2
0
        public async Task <string> PostRentMagicCustomerAsync(string path, string token, Customer customer)
        {
            Unit4Customer unit4Customer = null;

            unit4Customer = MapUnit4Customer(customer);

            var stringContent = new StringContent(JsonConvert.SerializeObject(unit4Customer), Encoding.UTF8, "application/json");

            client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token}");
            client.DefaultRequestHeaders.Add("Accept", "application/json");

            var result = await client.PostAsync("https://sandbox.api.online.unit4.nl/V21/api/MVL71239/Customer", stringContent);

            return("");
        }