public void CreatePicture(PictureBll picture)
        {
            if (picture == null)
                throw new ArgumentNullException("picture");

            var pictureDal = picture.ToDal();
            repository.Create(pictureDal);
            uow.Commit();
        }
        public void DeletePicture(PictureBll picture)
        {
            if (picture == null) throw new ArgumentNullException("picture");
            if (picture.Id <= 0)
                throw new InvalidIdException();

            var removedPicture = repository.GetById(picture.Id);

            if (removedPicture == null) throw
                new EntityNotFoundException("picture", picture.Id);

            repository.Delete(removedPicture);
            uow.Commit();
        }
        public void UpdatePicture(PictureBll picture)
        {
            if (picture == null)
                throw new ArgumentNullException("picture");

            PictureDal currentPicture = picture.ToDal();
            PictureDal existedPicture = repository.GetById(picture.Id);
            if (existedPicture == null)
                throw new EntityNotFoundException("picture", picture.Id);

            existedPicture.Image = currentPicture.Image;
            existedPicture.Hash = currentPicture.Hash;
            existedPicture.Name = currentPicture.Name;

            repository.Update(existedPicture);
            uow.Commit();
        }
        private int CreatePicture(AddPictureModel picture)
        {
            var imageBytes = picture.ImageFile.GetBytes();
            var newPicture = new PictureBll()
            {
                Name = picture.Name,
                Image = imageBytes,
                Hash = GetImageHash(imageBytes),
            };

            pictureService.CreatePicture(newPicture);

            PictureBll addedPic = pictureService
                                    .GetPicturesByHash(newPicture.Hash)
                                    .First(pic => pic.Name == picture.Name);
            return addedPic.Id;
        }