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); } }
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")); }