public ActionResult Create(ConcertCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateConcertService();

            if (service.CreateConcert(model))
            {
                TempData["SaveResult"] = "Concert has been created in Epiphany.";
                return(RedirectToAction("Index"));
            }
            ;
            ModelState.AddModelError("", "Concert could not be created in Epiphany.");
            return(View(model));
        }
Example #2
0
        public bool CreateConcert(ConcertCreate model)
        {
            var entity =
                new Concert()
            {
                OwnerId  = _userId,
                Artist   = model.Artist,
                TourName = model.TourName,
                City     = model.City,
                State    = model.State,
                Price    = model.Price,
                Date     = model.Date,

                CreatedUtc = DateTimeOffset.Now
            };

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