private void btnOk_Click(object sender, EventArgs e) { var director = (Person)cbxDirector.SelectedItem; var movie = new Movie(txtTitle.Text, (int)nudYear.Value) { Director = director }; //var movie = new Movie("Titanic", 1997) //{ // Duration = new TimeSpan(3, 14, 0), // Director = new Person { FirstName = "James", LastName = "Cameron" }, // Genres = new List<Genre> { Genre.Drama, Genre.Romance }, // ImdbId = "tt0120338", // Cast = new List<Person> // { // new Person {FirstName = "Leonardo", LastName = "Di Caprio" }, // new Person {FirstName = "Kate", LastName = "Winslet" }, // new Person {FirstName = "Billy", LastName = "Zane" }, // } //}; //scenario 1 //caller.AddMovie(movie); //scenario 2 //Movie = movie; //scenario 3 movieManager.AddMovie(movie); Close(); }
public ActionResult Add(string title, string director, string genre, string cast, int year, string award) { try { int ret = _movieManager.AddMovie(new MovieInfo(title, director, genre, cast, year, award)); return(Json(new ApiSuccess <int>(ret))); } catch (Exception ex) { return(Json(new ApiError($"{ex.Message}"))); } }
private static void TestData() { Genre g = new Genre { Name = "Actie" }; Genre g2 = new Genre { Name = "actie" }; Movie m = new Movie { Title = "Iron man", ReleaseDate = 2008, Genre = g }; Movie m2 = new Movie { Title = "Iron man 2", ReleaseDate = 2010, Genre = g }; Series s = new Series { Title = "Vikings", Season = 1, ReleaseDate = 2013, Genre = g2 }; _movieManager.AddMovie(m); _movieManager.AddMovie(m2); _movieManager.AddSeries(s); foreach (Media media in _movieManager.GetAllMedia()) { Console.WriteLine(media.ToString()); Console.WriteLine(media.Genre.Name); Console.WriteLine(); } }
public ActionResult Create([Bind(Include = "Id,Name,Director,Description")] Movie movie, HttpPostedFileBase image) { if (ModelState.IsValid) { movieManager.AddMovie(movie); // await db.SaveChangesAsync(); string filePath = Server.MapPath("~/images/" + movie.Id + ".jpg"); image.SaveAs(filePath); return(RedirectToAction("Index")); } ViewBag.Id = new SelectList(movieManager.GetAllMovies(), "MovieId", "Name"); return(View(movie)); }
public void DeleteMovie() { IMovieManager manager = new MovieManager(); Common.Movie movie = new Common.Movie { Id = 11, Name = "MovieName", Description = "SomeDescription", Rating = 4.0, URL = "http://someurl/img.png" }; bool result1 = manager.AddMovie(movie); bool result = manager.DeleteMovie(11); Assert.IsTrue(result); Common.Movie newMovie = manager.GetMovie(11); Assert.AreEqual(newMovie, null); }
public async Task <AddUserOutput> AddMovie(Movie movie) { return(await MovieManager.AddMovie(movie)); }
public static Movie AddMovie(int id, string name, string year) { return(MovManager.AddMovie(id, name, year)); }