示例#1
0
        public void InsertOrUpdateForm(string clientId, Form form)
        {
            _logger.LogDebug($"Upserting Form with ClientId: {clientId} and formId: {form.Id}");
            CloudTable      apiFormTable             = GetFormTable();
            FormTableEntity apiFormTableEntity       = form.ToFormEntity();
            TableOperation  insertOrReplaceOperation = TableOperation.InsertOrReplace(apiFormTableEntity);

            apiFormTable.ExecuteAsync(insertOrReplaceOperation);
        }
示例#2
0
        public static FormTableEntity ToFormEntity(this Form form)
        {
            if (form == null)
            {
                return(null);
            }
            var result = new FormTableEntity(form.ClientId, form.Id);

            result.ApiKey       = form.ApiKey;
            result.Cors         = form.Cors;
            result.Name         = form.Name;
            result.Desc         = form.Desc;
            result.FormTemplate = JsonConvert.SerializeObject(form.FormTemplate);

            return(result);
        }
示例#3
0
        public static Form ToForm(this FormTableEntity formEntity)
        {
            if (formEntity == null)
            {
                return(null);
            }
            var result = new Form();

            result.Id           = formEntity.RowKey;
            result.ClientId     = formEntity.PartitionKey;
            result.ApiKey       = formEntity.ApiKey;
            result.Cors         = formEntity.Cors;
            result.Name         = formEntity.Name;
            result.Desc         = formEntity.Desc;
            result.FormTemplate = JsonConvert.DeserializeObject <FormTemplate>(formEntity.FormTemplate);
            return(result);
        }
示例#4
0
        public void DeleteForm(string clientId, string formId)
        {
            _logger.LogDebug($"Deleting Form with ClientId: {clientId} and formId: {formId}");
            CloudTable     apiFormTable      = GetFormTable();
            TableOperation retrieveOperation = TableOperation.Retrieve <FormTableEntity>(clientId, formId);
            TableResult    retrievedResult   = apiFormTable.ExecuteAsync(retrieveOperation).Result;

            FormTableEntity deleteEntity = (FormTableEntity)retrievedResult.Result;

            // Create the Delete TableOperation
            if (deleteEntity != null)
            {
                TableOperation deleteOperation = TableOperation.Delete(deleteEntity);
                apiFormTable.ExecuteAsync(deleteOperation);
                _logger.LogDebug($"Deleted Form with ClientId: {clientId} and formId: {formId}");
            }
            else
            {
                _logger.LogDebug($"Nothing to delete - Form with ClientId: {clientId} and formId: {formId} does not exist");
            }
        }