Esempio n. 1
0
        public IHttpActionResult Putmovies(int id, visning movies)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != movies.id)
            {
                return(BadRequest());
            }

            db.Entry(movies).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public IHttpActionResult Getmovies(int id)
        {
            visning movies = db.visnings.Find(id);

            if (movies == null)
            {
                return(NotFound());
            }

            return(Ok(movies));
        }
Esempio n. 3
0
        public IHttpActionResult Postmovies(visning movies)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.visnings.Add(movies);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = movies.id }, movies));
        }
Esempio n. 4
0
        public IHttpActionResult Deletemovies(int id)
        {
            visning movies = db.visnings.Find(id);

            if (movies == null)
            {
                return(NotFound());
            }

            db.visnings.Remove(movies);
            db.SaveChanges();

            return(Ok(movies));
        }