예제 #1
0
        public bool CreateAppearance(AppearanceCreate model)
        {
            var entity =
                new Appearance()
            {
                UserId = _userId,

                ActorId = model.ActorId,
                MovieId = model.MovieId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Appearances.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
예제 #2
0
        public ActionResult Create(AppearanceCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            AppearanceService service = CreateAppearanceService();

            service.CreateAppearance(model);

            ViewBag.ActorId = new SelectList(service.Actors(), "ActorId", "Name", model.ActorId);
            ViewBag.MovieId = new SelectList(service.Movies(), "MovieId", "Title", model.MovieId);


            return(RedirectToAction("Index"));
        }