示例#1
0
        public IHttpActionResult Put(TvShowEdit tvShow)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateTvShowServices();

            if (!service.UpdateTvShow(tvShow))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
示例#2
0
        public bool UpdateTvShow(TvShowEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx
                             .TVShows
                             .Single(e => e.TvShowId == model.TvShowId);

                entity.TvShowId = model.TvShowId;
                entity.Title    = model.Title;
                entity.Seasons  = model.Seasons;
                entity.Episode  = model.Episode;
                entity.Ratings  = model.Ratings;
                return(ctx.SaveChanges() == 1);
            }
        }