Ejemplo n.º 1
0
 // PUT api/moviedvd/5
 public void Put(int id, MovieDvd movieDvd)
 {
     using (var ctx = new StoreEntities())
     {
         var movieDvdRaw = ctx.MovieDvds.Single(q => q.MovieDvdId == id);
         movieDvdRaw.Title = movieDvd.Title;
         movieDvdRaw.Price = movieDvd.Price;
         movieDvdRaw.MovieGenreId = movieDvd.Genre.Key;
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 // PUT api/moviedvd/5
 public void Put(int id, MovieDvd movieDvd)
 {
     using (var ctx = new StoreEntities())
     {
         var movieDvdRaw = ctx.MovieDvds.Single(q => q.MovieDvdId == id);
         movieDvdRaw.Title        = movieDvd.Title;
         movieDvdRaw.Price        = movieDvd.Price;
         movieDvdRaw.MovieGenreId = movieDvd.Genre.Key;
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 // GET api/moviedvd/5
 public MovieDvd Get(int id)
 {
     MovieDvd movieDvd = null;
     using (var ctx = new StoreEntities())
     {
         var dvdRaw = (from dvd in ctx.MovieDvds
                       where dvd.MovieDvdId == id
                       join genre in ctx.MovieGenres on dvd.MovieGenreId equals genre.MovieGenreId
                       select new { dvd, genre }).SingleOrDefault();
         if (dvdRaw != null)
         {
             movieDvd = new MovieDvd
             {
                 Id = dvdRaw.dvd.MovieDvdId,
                 Title = dvdRaw.dvd.Title,
                 Price = dvdRaw.dvd.Price,
                 Genre = new KeyValuePair<int, string>(dvdRaw.genre.MovieGenreId, dvdRaw.genre.Name)
             };
         }
     }
     return movieDvd;
 }
Ejemplo n.º 4
0
        // GET api/moviedvd/5
        public MovieDvd Get(int id)
        {
            MovieDvd movieDvd = null;

            using (var ctx = new StoreEntities())
            {
                var dvdRaw = (from dvd in ctx.MovieDvds
                              where dvd.MovieDvdId == id
                              join genre in ctx.MovieGenres on dvd.MovieGenreId equals genre.MovieGenreId
                              select new { dvd, genre }).SingleOrDefault();
                if (dvdRaw != null)
                {
                    movieDvd = new MovieDvd
                    {
                        Id    = dvdRaw.dvd.MovieDvdId,
                        Title = dvdRaw.dvd.Title,
                        Price = dvdRaw.dvd.Price,
                        Genre = new KeyValuePair <int, string>(dvdRaw.genre.MovieGenreId, dvdRaw.genre.Name)
                    };
                }
            }
            return(movieDvd);
        }