public async Task <IActionResult> PostPhoto([FromBody] ItemPhotos photo)
        {
            try
            {
                (photo != null).EntityHandleException();
                await _photoUploaderService.AddOurUpdatePhotoAsync(photo);

                return(Ok());
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);

                return(BadRequest());;
            }
        }
Beispiel #2
0
        public async Task <ItemPhotos> AddOurUpdatePhotoAsync(ItemPhotos entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity must not be null");
            }
            try
            {
                await _dbContext.AddAsync(entity);

                await _dbContext.SaveChangesAsync();

                return(entity);
            }
            catch (Exception e)
            {
                throw new Exception($"{nameof(entity)} could not be saved: {e.Message}");
            }
        }
 public async Task <ItemPhotos> AddOurUpdatePhotoAsync(ItemPhotos itemPhoto)
 {
     return(await _photoUploaderRepository.AddOurUpdatePhotoAsync(itemPhoto));
 }