private void SavePoster(HttpPostedFileBase[] files, int filmId) { if (files == null || filmId == 0) { return; } var image = files[0]; if (image != null) { DirectoryTools.CheckDirectoryExist(ImageOptions.PATH); var posters = posterSrv[filmId]; DeletePoster(posters); var poster = new PosterImageEntity { FilmId = filmId, MaxImage = ImageResize .Resize(image, ImageOptions.PATH, ImageOptions.IMAGE_WIDTH_MAX_VERTICAL, ImageOptions.IMAGE_HEIGHT_MAX_VERTICAL), MinImage = ImageResize .Resize(image, ImageOptions.PATH, ImageOptions.IMAGE_WIDTH_MIN_VERTICAL, ImageOptions.IMAGE_HEIGHT_MIN_VERTICAL) }; posterSrv.Add(poster); } }
public void Delete(PosterImageEntity image) { using (context = new CinemaStoreContext()) { try { context.Entry <PosterImageEntity>(image).State = System.Data.Entity.EntityState.Deleted; } catch (Exception ex) { throw ex; } context.SaveChanges(); } }
public void Add(PosterImageEntity image) { if (image == null) { return; } using (context = new CinemaStoreContext()) { context.PosterImage.Add(image); try { context.SaveChanges(); } catch (Exception ex) { throw ex; } } }