//Search Methods
 /// <summary>
 /// SearchItemsAsync uses the ScanAsync operator to retrieve items based on the conditions and options passed into it to retrieve a list of items from the table for IPersistentItem
 /// <remarks>[CAUTION] This operation can be very expensive if your table is large</remarks>
 /// </summary>
 /// <param name="conditions"></param>
 /// <param name="operationConfig"></param>
 /// <returns>A Task of IList of type TItem</returns>
 public virtual async Task <IList <TItem> > SearchItemsAsync(IEnumerable <ScanCondition> conditions, DynamoDBOperationConfig operationConfig = null)
 {
     return(await _dbContext
            .ScanAsync <TItem>(conditions, operationConfig)
            .GetNextSetAsync()
            .ConfigureAwait(false));
 }
Example #2
0
        public async Task <List <T> > QuerySecondaryIndexGetAllWithFilter <T>(object hashKeyValue, string indexName, List <ScanCondition> queryFilter, DynamoDBOperationConfig operationConfig = null)
        {
            if (operationConfig != null)
            {
                return(await DbContext.QueryAsync <T>(hashKeyValue, operationConfig).GetRemainingAsync());
            }

            return(await DbContext.QueryAsync <T>(hashKeyValue, new DynamoDBOperationConfig { IndexName = indexName, QueryFilter = queryFilter }).GetRemainingAsync());
        }
Example #3
0
 public DeckBuilderRepository(IConfiguration configuration)
 {
     _dbContext = new DynamoDBContext(new AmazonDynamoDBClient(RegionEndpoint.USEast2), new DynamoDBContextConfig());
     _dconfig   = new DynamoDBOperationConfig();
 }
        public new IAsyncSearchWrapper <T> QueryAsync <T>(object hashKeyValue, DynamoDBOperationConfig config = null)
        {
            var result = base.QueryAsync <T>(hashKeyValue, config);

            return(new AsyncSearchWrapper <T>(result));
        }
Example #5
0
 public async Task <List <T> > QueryGetAll <T>(object hashKeyValue, QueryOperator op, IEnumerable <object> values, DynamoDBOperationConfig operationConfig = null)
 {
     return(await DbContext.QueryAsync <T>(hashKeyValue, op, values, operationConfig).GetRemainingAsync());
 }
Example #6
0
 private static async Task <EventStoreModel> GetEventsAsync(IDynamoDBContext connection, Guid correlationId, DynamoDBOperationConfig configuration)
 => await connection.LoadAsync <EventStoreModel>(correlationId.ToString(), configuration);
Example #7
0
        public ContactPage()
        {
            this.SetBinding(ContentPage.TitleProperty, "FirstName");
            NavigationPage.SetHasNavigationBar(this, true);

            var firstNameLabel = new Label {
                Text = "First Name"
            };
            var firstNameEntry = new DoneEntry {
                Keyboard = Keyboard.Text
            };

            firstNameEntry.SetBinding(Entry.TextProperty, "FirstName");

            var lastNameLabel = new Label {
                Text = "Last Name"
            };
            var lastNameEntry = new DoneEntry {
                Keyboard = Keyboard.Text
            };

            lastNameEntry.SetBinding(Entry.TextProperty, "LastName");

            var homePhoneNumberLabel = new Label {
                Text = "Home Phone"
            };
            var homePhoneNumberEntry = new DoneEntry {
                Keyboard = Keyboard.Telephone
            };

            homePhoneNumberEntry.SetBinding(Entry.TextProperty, "HomePhoneNumber");

            var workPhoneNumberLabel = new Label {
                Text = "Work Phone"
            };
            var workPhoneNumberEntry = new DoneEntry {
                Keyboard = Keyboard.Telephone
            };

            workPhoneNumberEntry.SetBinding(Entry.TextProperty, "WorkPhoneNumber");

            var mobileNumberLabel = new Label {
                Text = "Mobile Number"
            };
            var mobileNumberEntry = new DoneEntry {
                Keyboard = Keyboard.Telephone
            };

            mobileNumberEntry.SetBinding(Entry.TextProperty, "MobileNumber");

            var emailLabel = new Label {
                Text = "Email"
            };
            var emailEntry = new DoneEntry {
                Keyboard = Keyboard.Email
            };

            emailEntry.SetBinding(Entry.TextProperty, "EmailAddress");

            var saveButton = new Button {
                Text = "Save"
            };

            saveButton.Clicked += async(sender, e) =>
            {
                var contact = (Contact)BindingContext;
                var id      = await AmazonUtils.Credentials.GetIdentityIdAsync();

                DynamoDBOperationConfig config = new DynamoDBOperationConfig
                {
                    IgnoreNullValues = false
                };
                if (string.IsNullOrEmpty(contact.UserId))
                {
                    var userId = Guid.NewGuid().ToString();
                    contact.Id     = id;
                    contact.UserId = userId;
                }
                await AmazonUtils.DDBContext.SaveAsync <Contact>(contact, config);

                Navigation.PopAsync();
            };

            var deleteButton = new Button {
                Text = "Delete", BorderColor = Color.Red, BorderRadius = 2
            };

            deleteButton.Clicked += async(sender, e) =>
            {
                var contact = (Contact)BindingContext;
                if (!string.IsNullOrEmpty(contact.UserId))
                {
                    contact.Id = await AmazonUtils.Credentials.GetIdentityIdAsync();

                    await AmazonUtils.DDBContext.DeleteAsync <Contact>(contact);
                }

                Navigation.PopAsync();
            };

            var cancelButton = new Button {
                Text = "Cancel", BorderColor = Color.Gray, BorderRadius = 2
            };

            cancelButton.Clicked += (sender, e) =>
            {
                Navigation.PopAsync();
            };

            Content = new ScrollView
            {
                Content = new StackLayout
                {
                    VerticalOptions = LayoutOptions.StartAndExpand,
                    Padding         = new Thickness(20),
                    Children        =
                    {
                        firstNameLabel,       firstNameEntry,
                        lastNameLabel,        lastNameEntry,
                        homePhoneNumberLabel, homePhoneNumberEntry,
                        workPhoneNumberLabel, workPhoneNumberEntry,
                        mobileNumberLabel,    mobileNumberEntry,
                        emailLabel,           emailEntry,
                        saveButton,           cancelButton, deleteButton
                    }
                }
            };
        }
 public AsyncSearch <T> QueryAsync <T>(object hashKeyValue, DynamoDBOperationConfig operationConfig = null)
 {
     throw new NotImplementedException();
 }
 public AsyncSearch <T> QueryAsync <T>(object hashKeyValue, QueryOperator op, IEnumerable <object> values,
                                       DynamoDBOperationConfig operationConfig = null)
 {
     throw new NotImplementedException();
 }
 public AsyncSearch <T> ScanAsync <T>(IEnumerable <ScanCondition> conditions, DynamoDBOperationConfig operationConfig = null)
 {
     throw new NotImplementedException();
 }
 public AsyncSearch <T> FromScanAsync <T>(ScanOperationConfig scanConfig, DynamoDBOperationConfig operationConfig = null)
 {
     throw new NotImplementedException();
 }
 public Task DeleteAsync <T>(object hashKey, object rangeKey, DynamoDBOperationConfig operationConfig,
                             CancellationToken cancellationToken = new CancellationToken())
 {
     throw new NotImplementedException();
 }
 public Task <T> LoadAsync <T>(T keyObject, DynamoDBOperationConfig operationConfig,
                               CancellationToken cancellationToken = new CancellationToken())
 {
     throw new NotImplementedException();
 }
 public Task <T> LoadAsync <T>(object hashKey, DynamoDBOperationConfig operationConfig,
                               CancellationToken cancellationToken = new CancellationToken())
 {
     return(null);
 }
Example #15
0
        public static async Task <EventsData> LoadEvensAsync(this IDynamoDBContext connection, Guid correlationId, IEnumerable <Type> knownTypes, DynamoDBOperationConfig configuration)
        {
            var data = await GetEventsAsync(connection, correlationId, configuration);

            var events = new List <object>();

            if (data is null)
            {
                return new EventsData {
                           Events = events, LastVersion = null
                }
            }
            ;

            events.AddRange(data.Events.SelectMany(@event => JsonSerialization.Deserialize(@event, knownTypes)));
            return(new EventsData {
                Events = events, LastVersion = data.Version
            });
        }
 public AsyncSearch <T> FromQueryAsync <T>(QueryOperationConfig queryConfig, DynamoDBOperationConfig operationConfig = null)
 {
     throw new NotImplementedException();
 }
Example #17
0
        public static async Task SaveEvensAsync(this IDynamoDBContext connection, Guid correlationId, IEnumerable <object> changes, DynamoDBOperationConfig configuration)
        {
            var data = await GetEventsAsync(connection, correlationId, configuration) ?? new EventStoreModel
            {
                CorrelationId = correlationId.ToString(), Metadata = new EventMetadata {
                    StartedAt = DateTime.UtcNow
                }
            };

            var events = changes.Select(change => new EventModel
            {
                Id        = Guid.NewGuid().ToString(),
                Type      = TypeMapping.GetTypeName(change.GetType()),
                Data      = JsonConvert.SerializeObject(change),
                Timestamp = DateTime.UtcNow
            });

            data.Events.AddRange(events);
            data.Metadata.UpdatedAt = DateTime.UtcNow;

            await connection.SaveAsync(data, configuration);
        }
 public Table GetTargetTable <T>(DynamoDBOperationConfig operationConfig = null)
 {
     throw new NotImplementedException();
 }
 public FamilyEventReadRepository(IAWSClientFactory awsClientFactory, DynamoDBOperationConfig operationConfig)
 {
     _awsClientFactory = awsClientFactory;
     _operationConfig  = operationConfig;
 }
 public Document ToDocument <T>(T value, DynamoDBOperationConfig operationConfig)
 {
     throw new NotImplementedException();
 }
        public new IAsyncSearchWrapper <T> ScanAsync <T>(IEnumerable <ScanCondition> conditions, DynamoDBOperationConfig config = null)
        {
            var result = base.ScanAsync <T>(conditions, config);

            return(new AsyncSearchWrapper <T>(result));
        }
 public T FromDocument <T>(Document document, DynamoDBOperationConfig operationConfig)
 {
     throw new NotImplementedException();
 }
 public UnionWriteRepository(IAWSClientFactory awsClientFactory, DynamoDBOperationConfig dynamoDBOperationConfig)
 {
     _clientFactory           = awsClientFactory;
     _dynamoDBOperationConfig = dynamoDBOperationConfig;
 }
 public IEnumerable <T> FromDocuments <T>(IEnumerable <Document> documents, DynamoDBOperationConfig operationConfig)
 {
     throw new NotImplementedException();
 }
Example #25
0
        public async Task <List <T> > QuerySecondaryIndexGetAll <T>(object hashKeyValue, QueryOperator op, IEnumerable <object> values, string indexName, DynamoDBOperationConfig operationConfig = null)
        {
            if (operationConfig != null)
            {
                return(await DbContext.QueryAsync <T>(hashKeyValue, op, values, operationConfig).GetRemainingAsync());
            }

            return(await DbContext.QueryAsync <T>(hashKeyValue, op, values, new DynamoDBOperationConfig { IndexName = indexName }).GetRemainingAsync());
        }
 public BatchWrite <T> CreateBatchWrite <T>(DynamoDBOperationConfig operationConfig = null)
 {
     throw new NotImplementedException();
 }
Example #27
0
 public ImageReferenceWriteRepository(IAWSClientFactory awsClientFactory, DynamoDBOperationConfig dynamoDBOperationConfig)
 {
     _clientFactory           = awsClientFactory;
     _dynamoDBOperationConfig = dynamoDBOperationConfig;
 }
 public Task SaveAsync <T>(T value, DynamoDBOperationConfig operationConfig,
                           CancellationToken cancellationToken = new CancellationToken())
 {
     throw new NotImplementedException();
 }
Example #29
0
 public StoryReadRepository(IAWSClientFactory awsClientFactory, DynamoDBOperationConfig dynamoDBOperationConfig)
 {
     _clientFactory           = awsClientFactory;
     _dynamoDBOperationConfig = dynamoDBOperationConfig;
 }
        /// <inheritdoc />.
        public async Task <ICollection <TEntity> > QueryAsync(TKey key, DynamoDBOperationConfig config)
        {
            var query = _context.QueryAsync <TEntity>(key, config);

            return(await query.GetRemainingAsync());
        }