public ActionResult Create(Movie currMovie) { try { var context = new MovieEntities(); using (context) { var director = GetPeople(currMovie, context, Kind.Director); var maleActor = GetPeople(currMovie, context, Kind.MaleActor); var femaleActor = GetPeople(currMovie, context, Kind.FemaleActor); var movieToAdd = new Movies() { title = currMovie.Title, year = currMovie.Year, directorId = director.id, leadingMaleRoleId = maleActor.id, leadingFemaleRoleId = femaleActor.id }; context.Movies.Add(movieToAdd); context.SaveChanges(); } return View(); } catch { return View("Error"); } }
private Movie GenerateMovieModel(Movies movie) { var movieModel = new Movie() { Id = movie.id, Title = movie.title, Year = movie.year, Director = new MoviesCrud.ViewModels.People() { FirstName = movie.Director.firstName, LastName = movie.Director.lastName, Age = movie.Director.age, Studio = new MoviesCrud.ViewModels.Studio() { Address = movie.Director.Studio.address, Name = movie.Director.Studio.name } }, LeadingFemale = new MoviesCrud.ViewModels.People() { FirstName = movie.LeadingFemale.firstName, LastName = movie.LeadingFemale.lastName, Age = movie.LeadingFemale.age, Studio = new MoviesCrud.ViewModels.Studio() { Address = movie.LeadingFemale.Studio.address, Name = movie.LeadingFemale.Studio.name } }, LeadingMale = new MoviesCrud.ViewModels.People() { FirstName = movie.LeadingMale.firstName, LastName = movie.LeadingMale.lastName, Age = movie.LeadingMale.age, Studio = new MoviesCrud.ViewModels.Studio() { Address = movie.LeadingMale.Studio.address, Name = movie.LeadingMale.Studio.name } } }; return movieModel; }