Exemplo n.º 1
0
        public Task <UserModel> FindUserByEmail(string email)
        {
            logWriter.LogInformation($"{nameof(FindUserByEmail)}({nameof(email)} = '{email}')");

            var request = new GetItemRequest(tableName, new Dictionary <string, AttributeValue>
            {
                { "PartitionKey", new AttributeValue(email.ToLowerInvariant()) },
                { "SortKey", new AttributeValue("user") }
            });

            return(dynamoDbCore.GetItem(request, Mappers.UserModel, UserModel.Null));
        }
Exemplo n.º 2
0
        public Task <SettingsModel> GetSettings(string settingsDomain)
        {
            GetItemRequest request = new GetItemRequest
            {
                TableName = tableName,
                Key       = Mappers.Settings.ToDbKey(new SettingsModel {
                    Domain = settingsDomain
                })
            };

            return(dynamoDbCore.GetItem(request, Mappers.Settings));
        }
        public async Task <PhotoState> GetPhotoState(PhotoId photoId)
        {
            logWriter.LogInformation($"{nameof(GetPhotoState)}({nameof(photoId)} = '{photoId}')");

            var request = new GetItemRequest(tableName, new Dictionary <string, AttributeValue>
            {
                { FieldMappings.PartitionKey, new AttributeValue(photoId.ToDbValue()) },
                { FieldMappings.SortKey, new AttributeValue(photoId.ToDbValue()) }
            });

            var photo = await dynamoDbCore.GetItem(request, Mappers.PhotoModel);

            if (photo == null)
            {
                logWriter.LogInformation($"No photo found for id '{photoId.ToDbValue()}'");
                return(PhotoState.Undefined);
            }

            return(photo.State);
        }