コード例 #1
0
 public void CreatePoster(Models.Poster poster)
 {
     using (var context = new PosterManagementServicePrototype.Models.PosterManagementContext())
     {
         context.Entry(poster).State = System.Data.Entity.EntityState.Added;
         context.SaveChanges();
     }
 }
コード例 #2
0
        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");
                }
            }
        }