public dynamic Save(object model)
        {
            IDynamicAmplaViewProperties amplaViewProperties = viewProperties;

            amplaViewProperties.Enforce.CanAdd();

            SubmitDataRequest request = new SubmitDataRequest {
                Credentials = CreateCredentials()
            };
            List <SubmitDataRecord> records = new List <SubmitDataRecord>();
            List <object>           models  = new List <object> {
                model.ToExpando()
            };

            IAmplaBinding binding = new AmplaAddDataDynamicBinding(models, records, amplaViewProperties, modelProperties);

            if (binding.Validate() && binding.Bind())
            {
                request.SubmitDataRecords = records.ToArray();
                SubmitDataResponse response = webServiceClient.SubmitData(request);

                IAmplaBinding resultBinding = new AmplaDataSubmissionResultDynamicBinding(response.DataSubmissionResults, models);
                if (resultBinding.Validate())
                {
                    resultBinding.Bind();
                }
            }
            return(models[0]);
        }
Example #2
0
 public AmplaAddDataDynamicBinding(List <dynamic> models, List <SubmitDataRecord> records,
                                   IDynamicAmplaViewProperties amplaViewProperties,
                                   IDynamicModelProperties modelProperties)
 {
     this.models              = models;
     this.records             = records;
     this.amplaViewProperties = amplaViewProperties;
     this.modelProperties     = modelProperties;
 }