示例#1
0
        public int Add(IMovieViewModel movie, HttpPostedFileBase image)
        {
            if (image == null)
            {
                throw new ImageNotFoundException();
            }

            movie.Image = new byte[image.ContentLength];
            image.InputStream.Read(movie.Image, 0, image.ContentLength);

            _uOW.EFMovieRepository.Add(movie.ToDtoModel().ToSqlModel());
            _uOW.Save();

            return(movie.Id);
        }
示例#2
0
        public void Update(IMovieViewModel movie, HttpPostedFileBase image)
        {
            var oldMovie = GetItem(movie.Id);

            if (oldMovie.Image == null && image == null)
            {
                throw new ImageNotFoundException();
            }

            if (image == null)
            {
                movie.Image = oldMovie.Image;
            }
            else
            {
                movie.Image = new byte[image.ContentLength];
                image.InputStream.Read(movie.Image, 0, image.ContentLength);
            }

            _uOW.EFMovieRepository.Update(movie.ToDtoModel().ToSqlModel());
            _uOW.Save();
        }