public void CreatePoster(Models.Poster poster) { using (var context = new PosterManagementServicePrototype.Models.PosterManagementContext()) { context.Entry(poster).State = System.Data.Entity.EntityState.Added; context.SaveChanges(); } }
public Models.Poster UpdatePoster(Models.Poster poster) { using (var context = new PosterManagementServicePrototype.Models.PosterManagementContext()) { if (context.Posters.Any(p => p.Id == poster.Id)) { context.Entry(poster).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(poster); } else { throw new InvalidOperationException("That poster doesn't exist"); } } }