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); }
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(); }