예제 #1
0
        // private readonly Guid _userId;
        //   public TvShowServices (Guid userId)
        // {
        //   _userId = userId;
        //}

        public bool CreateTvShow(TvShowCreate model)
        {
            var tvShow = new TVShow
            {
                //  OwnerId =_userId,
                Title   = model.Title,
                Seasons = model.Seasons,
                Episode = model.Episode
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.TVShows.Add(tvShow);

                return(ctx.SaveChanges() > 0);
            }
        }
예제 #2
0
        public IHttpActionResult Post(TvShowCreate model)
        {
            if (model is null)
            {
                return(BadRequest(ModelState));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var  service     = CreateTvShowServices();
            bool isSucessful = service.CreateTvShow(model);

            if (isSucessful)
            {
                return(Ok($"Customer Created: {model.Title}"));
            }
            return(InternalServerError());
        }