// POST: api/MovieData
 public void Post([FromBody] MovieViewModel movie)
 {
     // validare
     using (var db = new angularEntities1())
     {
         db.Set <Movie>().Add(MovieViewModelToDbModel(movie));
         db.SaveChanges();
     }
 }
示例#2
0
        public IHttpActionResult PutActor(int id, Actor actor)
        {
            db.Entry(actor).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ActorExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#3
0
        public IHttpActionResult DeleteActor(int id)
        {
            using (var db = new angularEntities1())
            {
                var existingActor = db.Actors.Where(s => s.Id_Actor == id)
                                    .FirstOrDefault <Actor>();

                if (existingActor == null)
                {
                    return(NotFound());
                }
                else
                {
                    db.Actors.Remove(existingActor);
                    db.SaveChanges();
                }
            }

            return(Ok());
        }
        public IHttpActionResult DeleteMovie(int movieId)
        {
            using (var db = new angularEntities1())
            {
                var existingMovie = db.Movies.Where(s => s.Id_Movies == movieId)
                                    .FirstOrDefault <Movie>();

                if (existingMovie == null)
                {
                    return(NotFound());
                }
                else
                {
                    db.Movies.Remove(existingMovie);
                    db.SaveChanges();
                }
            }

            return(Ok());
        }
        // PUT: api/MovieData/5
        public IHttpActionResult Put([FromBody] MovieViewModel movie)
        {
            using (var db = new angularEntities1())
            {
                var existingMovie = db.Movies.Where(s => s.Id_Movies == movie.Id_movie)
                                    .FirstOrDefault <Movie>();

                if (existingMovie != null)
                {
                    existingMovie.Denumire       = movie.Denumire;
                    existingMovie.Genul          = movie.Genul;
                    existingMovie.Anul_Prductiei = movie.Anul_Prductiei;

                    db.SaveChanges();
                }
                else
                {
                    return(NotFound());
                }
            }

            return(Ok());
        }