Beispiel #1
0
        /// <summary>
        /// Deletes the records.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public DeleteRecordsResponse DeleteRecords(DeleteRecordsRequest request)
        {
            return(TryCatchThrowFault(() =>
            {
                DateTime editTime = DateTime.Now;
                List <DeleteRecordsResult> results = new List <DeleteRecordsResult>();
                string user = CheckCredentials(request.Credentials);
                foreach (DeleteRecord deleteRecord in request.DeleteRecords)
                {
                    Dictionary <int, InMemoryRecord> database = amplaDatabase.GetModuleRecords(deleteRecord.Module.ToString());

                    CheckReportingPoint(deleteRecord.Module.ToString(), deleteRecord.Location);
                    int recordId = (int)deleteRecord.MergeCriteria.SetId;
                    InMemoryRecord record = FindRecord(database, deleteRecord.Location, deleteRecord.Module, recordId);
                    FieldValue deleted = record.Find("Deleted");
                    if (deleted != null)
                    {
                        record.Fields.Remove(deleted);
                    }
                    record.Fields.Add(new FieldValue("Deleted", "True"));
                    AddAuditRecord(record, editTime, "IsDeleted", false.ToString(), true.ToString(), user);

                    results.Add(new DeleteRecordsResult
                    {
                        Location = deleteRecord.Location,
                        Module = deleteRecord.Module,
                        RecordAction = DeleteRecordsAction.Delete,
                        SetId = recordId
                    });
                }
                return new DeleteRecordsResponse {
                    DeleteRecordsResults = results.ToArray()
                };
            }));
        }
        /// <summary>
        /// Deletes a batch of records.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <ApiResponse> DeleteRecordsAsync(DeleteRecordsRequest request)
        {
            Arg.IsNotNull(request, nameof(request));

            var path        = UrlHelper.GetBatchDeleteRecordsPath();
            var apiResponse = await PostAsync(path, request);

            return(apiResponse);
        }
Beispiel #3
0
        /// <summary>
        /// Deletes the specified model.
        /// </summary>
        /// <param name="model">The model.</param>
        public void Delete(TModel model)
        {
            IAmplaViewProperties <TModel> amplaViewProperties = GetViewProperties(model);

            amplaViewProperties.Enforce.CanDelete();

            DeleteRecordsRequest request = new DeleteRecordsRequest {
                Credentials = CreateCredentials()
            };
            List <DeleteRecord> records = new List <DeleteRecord>();
            List <TModel>       models  = new List <TModel> {
                model
            };

            IAmplaBinding binding = new AmplaDeleteDataBinding <TModel>(models, records, ModelProperties);

            if (binding.Validate() && binding.Bind())
            {
                request.DeleteRecords = records.ToArray();
                WebServiceClient.DeleteRecords(request);
            }
        }
 public DeleteRecordsResponse DeleteRecords(DeleteRecordsRequest request)
 {
     return(Create().DeleteRecords(request));
 }
Beispiel #5
0
        public static void Example1()
        {
            everymessageCredential credential = everymessageCredential.Create("demo", "2sd3ODILm5wXzcWPPKe4CwPK9gDEPk@JsAL7q9!pKANCJWtwN0!skDRta67z@NvY");
            WorkflowClient         client     = WorkflowClient.Create("https://api.everymessage.com/workflow/", credential);

            // SUBMIT example

            SubmitRecordsRequest submitRequest = new SubmitRecordsRequest()
            {
                InstanceName = "demo_simple_sms",
                Records      = new List <WorkflowRecord>()
                {
                    new WorkflowRecord()
                    {
                        PrimaryReference = "DEMO001",
                        FirstName        = "Mark",
                        PhoneNumber      = "07777777777",
                        Variables        = new List <WorkflowVariable>()
                        {
                            WorkflowVariable.Create("amount", 311.24M),
                            WorkflowVariable.Create("due", DateTime.Now.ToString("dd MMM yyyy"))
                        }
                    },
                    new WorkflowRecord()
                    {
                        PrimaryReference = "DEMO002",
                        FirstName        = "Hannah",
                        PhoneNumber      = "07777777778",
                        Variables        = new List <WorkflowVariable>()
                        {
                            WorkflowVariable.Create("amount", 16.07M),
                            WorkflowVariable.Create("due", DateTime.Now.ToString("dd MMM yyyy"))
                        }
                    }
                }
            };

            var submitResponse = client.SubmitRecords(submitRequest);

            // QUERY example

            QueryRecordsRequest queryRequest = new QueryRecordsRequest()
            {
                Records = new List <long>()
                {
                    submitResponse.Body.Records[0].WorkflowRecordId, submitResponse.Body.Records[1].WorkflowRecordId
                },
                IncludeActivities       = true,
                IncludeSmsInformation   = true,
                IncludeEmailInformation = true,
                IncludeRepositoryData   = true
            };

            var queryResponse = client.QueryRecords(queryRequest);

            // DELETE example

            DeleteRecordsRequest deleteRequest = new DeleteRecordsRequest()
            {
                Records = new List <long>()
                {
                    submitResponse.Body.Records[0].WorkflowRecordId, submitResponse.Body.Records[1].WorkflowRecordId
                }
            };

            var deleteResponse = client.DeleteRecords(deleteRequest);

            Console.Read();
        }
Beispiel #6
0
        public async Task CrudAsync()
        {
            // Prepare initial record.
            var record = TestDataFactory.GetFullyFilledOutRecord(_appIdWithRecords, default);

            // Insert
            var insertResponse = await _apiClient.SaveRecordAsync(record);       // Used for single delete

            var secondInsertResponse = await _apiClient.SaveRecordAsync(record); // Used for batch delete

            AssertHelper.AssertSuccess(insertResponse);

            // Update
            record.RecordId = insertResponse.Value.Id;
            UpdateRecordFields(record);

            var updateResponse = await _apiClient.SaveRecordAsync(record);

            AssertHelper.AssertSuccess(updateResponse);

            // Reads
            // Get by ID
            var getRequest = new GetRecordRequest(_appIdWithRecords, insertResponse.Value.Id)
            {
                FieldIds = { _fieldId },
            };
            var getResponse = await _apiClient.GetRecordAsync(getRequest);

            AssertHelper.AssertSuccess(getResponse);
            AssertHelper.AssertCasting(getResponse.Value);

            // Get batch
            var getBatchRequest = new GetRecordsRequest
            {
                AppId     = _appIdWithRecords,
                RecordIds = { insertResponse.Value.Id, secondInsertResponse.Value.Id },
                FieldIds  = { _fieldId },
            };
            var batchGetResponse = await _apiClient.GetRecordsAsync(getBatchRequest);

            AssertHelper.AssertSuccess(batchGetResponse);
            AssertHelper.AssertCasting(batchGetResponse.Value.Items);

            // Get by app
            var pagingRequest   = new PagingRequest(1, 10);
            var getByAppRequest = new GetRecordsByAppRequest(_appIdWithRecords, pagingRequest)
            {
                FieldIds = { _fieldId },
            };
            var getByAppResponse = await _apiClient.GetRecordsForAppAsync(getByAppRequest);

            AssertHelper.AssertSuccess(getByAppResponse);
            AssertHelper.AssertCasting(getByAppResponse.Value.Items);

            // Query
            var queryRequest = new QueryRecordsRequest
            {
                AppId = _appIdWithRecords,
            };
            var queryResponse = await _apiClient.QueryRecordsAsync(queryRequest);

            AssertHelper.AssertSuccess(queryResponse);
            AssertHelper.AssertCasting(queryResponse.Value.Items);

            // Delete
            // Single delete
            var deleteResponse = await _apiClient.DeleteRecordAsync(_appIdWithRecords, insertResponse.Value.Id);

            AssertHelper.AssertSuccess(deleteResponse);

            // Batch delete
            var batchDeleteRequest  = new DeleteRecordsRequest(_appIdWithRecords, new[] { secondInsertResponse.Value.Id });
            var batchDeleteResponse = await _apiClient.DeleteRecordsAsync(batchDeleteRequest);

            AssertHelper.AssertSuccess(batchDeleteResponse);
        }
Beispiel #7
0
 public DeleteRecordsResponse DeleteRecords(DeleteRecordsRequest request)
 {
     logger.Log("DeleteRecords ({0})", request);
     return(implementation.DeleteRecords(request));
 }
Beispiel #8
0
 public IActionResult DeleteBatch(DeleteRecordsRequest request)
 {
     return(Ok());
 }