Exemplo n.º 1
0
        public IHttpActionResult Post(PostShow show)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateShowService();

            if (!service.CreateShow(show))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
Exemplo n.º 2
0
        public bool CreateShow(PostShow model)
        {
            var entity =
                new Show()
            {
                Title       = model.Title,
                Description = model.Description,
                Genre       = (ShowGenre)model.Genre
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Shows.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }