public async Task <IBlobMetaData> AddAsync(string blobId, BlobMetaDataCreateModel blobMetaDataModel)
        {
            BlobMetaData metaData = null;

            if (_dbContext.BlobMetaDatas.Any(x => x.BlobId == blobId && x.Key == blobMetaDataModel.Key))
            {
                metaData = await UpdateAsync(blobId, blobMetaDataModel.Key, blobMetaDataModel.Value) as BlobMetaData;
            }
            else
            {
                var newMetaData = new BlobMetaData
                {
                    BlobId = blobId,
                    Key    = blobMetaDataModel.Key,
                    Value  = blobMetaDataModel.Value
                };

                await _dbContext.BlobMetaDatas.AddAsync(newMetaData);

                metaData = newMetaData;
            }

            await _dbContext.SaveChangesAsync();

            return(metaData);
        }
Ejemplo n.º 2
0
 public async Task <IBlobMetaData> AddAsync(string blobId, BlobMetaDataCreateModel blobMetaDataModel)
 {
     return(await Task.FromResult(new BlobMetaDataTest()
     {
         Id = "New_Id",
         Key = "Key",
         Value = "Value"
     }));
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> UpdateMetaDataAsync(string blobId, [FromBody] BlobMetaDataCreateModel model)
        {
            if (string.IsNullOrEmpty(blobId) || model == null)
            {
                return(BadRequest());
            }

            var blob = await _blobStore.GetByIdAsync(blobId);

            if (blob == null)
            {
                return(NotFound());
            }

            var metaData = await _blobMetaDataStore.UpdateAsync(blobId, model.Key, model.Value);

            return(Ok(metaData));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> SetMetaDataAsync(string blobId, [FromBody] BlobMetaDataCreateModel model)
        {
            if (string.IsNullOrEmpty(blobId) || model == null)
            {
                return(BadRequest());
            }

            var blob = await _blobStore.GetByIdAsync(blobId);

            if (blob == null)
            {
                return(NotFound());
            }

            var metaData = await _blobMetaDataStore.AddAsync(blobId, model);

            return(Ok(ModelMapper.ToViewModel(metaData)));
        }