Пример #1
0
        public NextPage.SupportSync.Zapier.Customer AddEditCustomer()
        {
            Request.InputStream.Seek(0, SeekOrigin.Begin);
            string jsonObj = new StreamReader(Request.InputStream).ReadToEnd();

            var customer = JsonConvert.DeserializeObject <NextPage.SupportSync.Zapier.Customer>(jsonObj.ToString());
            Dictionary <string, string> values = JsonConvert.DeserializeObject <Dictionary <string, string> >(jsonObj.ToString());

            var fields = new List <NextPage.SupportSync.Zapier.CustomerField>();

            foreach (var val in values)
            {
                if (!PropertyUtils.Exists(val.Key, customer))
                {
                    fields.Add(new NextPage.SupportSync.Zapier.CustomerField {
                        CustomerId = customer.CustomerId, FieldName = val.Key, FieldValue = val.Value
                    });
                }
            }
            customer.CustomerFieldList = fields;
            MvcApplication.zap.AddEditCustomer(customer);
            return(customer);
        }