public async Task <IActionResult> Post([FromForm] ValueForAddedDto valueForAdded)
        {
            var value = mapper.Map <Value>(valueForAdded);
            var file  = valueForAdded.File;

            repository.Add(value);
            if (await repository.SaveAll())
            {
                await SavePhoto(value, file);

                return(Ok(value));
            }


            return(BadRequest("Nie udało sie dodać do bazy"));
        }
        public async Task <IActionResult> AddedPhotoForValue(int valueId, [FromForm] PhotoForCreationDto photoForCreation)
        {
            var value = await repository.GetValue(valueId);

            var file         = photoForCreation.File;
            var uploadResult = new ImageUploadResult();

            if (file.Length > 0)
            {
                using (var stream = file.OpenReadStream())
                {
                    var uploadParams = new ImageUploadParams()
                    {
                        File = new FileDescription(file.Name, stream)
                    };

                    uploadResult = cloudinary.Upload(uploadParams);
                };
            }

            photoForCreation.Url      = uploadResult.Uri.ToString();
            photoForCreation.PublicId = uploadResult.PublicId;

            var photo = mapper.Map <Photo>(photoForCreation);

            if (!value.Photos.Any(p => p.IsMain))
            {
                photo.IsMain = true;
            }

            value.Photos.Add(photo);

            if (await repository.SaveAll())
            {
                var photoForReturn = mapper.Map <PhotoForReturnDto>(photo);
                return(CreatedAtRoute("GetPhoto", new { id = photo.Id }, photoForReturn));
            }


            return(BadRequest("Nie udało się dodać zdjęcia"));
        }