Example #1
0
        //Create a new destination
        public bool CreateDestination(DestCreate model)
        {
            var entity =
                new Destination()
            {
                DestName = model.DestName,
                GenreId  = model.GenreId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Destinations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public IHttpActionResult Post(DestCreate destination)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateDestService();

            if (!service.CreateDestination(destination))
            {
                return(InternalServerError());
            }
            return(Ok());
        }