public void CreateNewDb() { foreach (var language in LangaugeCreator.GetAll()) { _db.Languages.Add(language); } foreach (var sites in WebSiteCreator.GetAllCriticSites()) { _db.CriticSites.Add(sites); } foreach (var movie in MovieCreator.CreateMovies()) { _db.Movies.Add(movie); } foreach (var movieDetail in MovieDetailCreator.CreateMovies()) { _db.MovieDetails.Add(movieDetail); } foreach (var criticRating in CriticRatingCreator.CreateCriticRatings()) { _db.CriticRatings.Add(criticRating); } foreach (var userRating in UserRatingCreator.CreateUserRating()) { _db.UserRatings.Add(userRating); } _db.SaveChanges(); }
public void AddMovie(MovieCreator mov) { using (var connection = new SqlConnection(_connectionString)) { string sqlInsert = "INSERT INTO Movie VALUES (NEWID(),@Tit, @y, @g, @t, @r,@key)"; var creatorList = connection.Query <Creator>("Select * From Creator").ToList(); connection.Execute(sqlInsert, new { Tit = mov.Title, y = mov.Year, g = mov.Genre, t = mov.Type, r = mov.Rating, key = creatorList.Find(item => item.Name.Trim() == mov.Name).Pk_Creator_Id }); } }
public ActionResult DelMovie(int id = 0) { MOVIEADVISOREntities6 entities = new MOVIEADVISOREntities6(); MovieCreator creator = new MovieCreator(); creator.RemoveMovie(entities.MOVIES.Where(m => m.ID == id).First()); return(RedirectToAction("New")); }
public void EditMovie(MovieCreator mov) { using (var connection = new SqlConnection(_connectionString)) { string sqlUpdate = "UPDATE Movie SET Year=@y, Genre=@g, Type=@t, Rating=@r,Fk_Creator_Id=@key WHERE Title=@title"; Console.WriteLine("Enter the creator's name"); var creators = connection.Query <Creator>("Select * From Creator;").ToList(); var x = creators.Find(item => item.Name.Trim().ToUpper() == mov.Name.Trim().ToUpper()).Pk_Creator_Id; connection.Execute(sqlUpdate, new { y = mov.Year, g = mov.Genre, t = mov.Type, r = mov.Rating, key = x, title = mov.Title }); } }
public async Task <StatusCodeResult> MovieCreators() { var movieIds = ( from m in _context.Movies join mc in _context.MovieCreators on m.Id equals mc.MovieId into mcs // LEFT JOIN from mc in mcs.DefaultIfEmpty() where (mc.CreatorId as int?) == null select m.Id ).Distinct(); { int i = 0; foreach (var id in movieIds) { var movieDetails = await RequestMovieDetails(id); foreach (var company in movieDetails.Production_Companies) { var creator = new Creator { Id = company.Id, Name = company.Name }; if (!_context.Creators.Contains(creator)) { _context.Creators.Attach(creator); _context.Creators.Add(creator); await _context.SaveChangesAsync(); } var movieCreator = new MovieCreator { CreatorId = creator.Id, MovieId = id }; _context.MovieCreators.Attach(movieCreator); _context.MovieCreators.Add(movieCreator); } await _context.SaveChangesAsync(); if (i % 40 == 0) { await Task.Delay(10000); } i++; } } return(Ok()); }
public void MergeVideos(string[] pathNames, string outputPath) { List <Movie> inMovies = new List <Movie>(); Movie movie = new Movie(); foreach (string path in pathNames) { inMovies.Add(MovieCreator.Build(path)); } List <List <ITrack> > allTracks = new List <List <ITrack> >(); for (int i = 0; i < pathNames.Length; i++) { allTracks.Add(new List <ITrack>()); } for (int i = 0; i < inMovies.Count(); i++) { foreach (ITrack track in inMovies[i].Tracks) { allTracks[i].Add(track); } } ITrack[] tracks = new ITrack[allTracks.Count()]; for (int i = 0; i < allTracks[0].Count(); i++) { for (int j = 0; j < allTracks.Count(); j++) { tracks[j] = allTracks[j][i]; } movie.AddTrack(new AppendTrack(tracks)); tracks = new ITrack[allTracks.Count()]; } BasicContainer oout = (BasicContainer) new DefaultMp4Builder().Build(movie); FileOutputStream fos = new FileOutputStream(new File(outputPath)); oout.WriteContainer(fos.Channel); fos.Close(); }
private static void Add() { var desktopRepo = new Desktop(); var newM = new MovieCreator(); Console.WriteLine("Enter a new title"); newM.Title = Console.ReadLine(); Console.WriteLine("Enter the year"); newM.Year = int.Parse(Console.ReadLine() ?? throw new InvalidOperationException("Enter a valid Year")); Console.WriteLine("Enter the genre"); newM.Genre = Console.ReadLine(); Console.WriteLine("Enter the type"); newM.Type = Console.ReadLine(); Console.WriteLine("Enter the rating"); newM.Rating = int.Parse(Console.ReadLine() ?? throw new InvalidOperationException("Enter a valid Rating(1-5)")); Console.WriteLine("Enter an author"); newM.Name = Console.ReadLine(); desktopRepo.Add(newM); }
// You can merge any amount of movies, but some format are less stable public void Merge(string sourceDirectory, string movie1, string movie2, string destinationDirectory, string destinationFile) { var inMovies = new Com.Googlecode.Mp4parser.Authoring.Movie[] { MovieCreator.Build(Path.Combine(sourceDirectory, movie1)), MovieCreator.Build(Path.Combine(sourceDirectory, movie2)), }; var videoTracks = new List <ITrack>(); var audioTracks = new List <ITrack>(); foreach (var m in inMovies) { foreach (var t in m.Tracks) { if (t.Handler.Equals("soun")) { audioTracks.Add(t); } if (t.Handler.Equals("vide")) { videoTracks.Add(t); } } } var result = new Com.Googlecode.Mp4parser.Authoring.Movie(); if (audioTracks.Count > 0) { result.AddTrack(new AppendTrack(audioTracks.ToArray())); } if (videoTracks.Count > 0) { result.AddTrack(new AppendTrack(videoTracks.ToArray())); } var outContainer = new DefaultMp4Builder().Build(result); var fc = new FileOutputStream(Path.Combine(destinationDirectory, destinationFile)).Channel; outContainer.WriteContainer(fc); fc.Close(); }
private static void Edit() { var desktopRepo = new Desktop(); var newM = new MovieCreator(); Console.WriteLine("Add Title."); newM.Title = Console.ReadLine(); Console.WriteLine("Enter changed Year"); newM.Year = int.Parse(Console.ReadLine() ?? throw new InvalidOperationException("Enter a valid Year")); Console.WriteLine("Enter changed Genre"); newM.Genre = Console.ReadLine(); Console.WriteLine("Enter changed Type"); newM.Type = Console.ReadLine(); Console.WriteLine("Please enter a rating between 1 and 5."); newM.Rating = int.Parse(Console.ReadLine() ?? throw new InvalidOperationException("Enter a valid Rating(1-5)")); Console.WriteLine("Please enter the author's name"); newM.Name = Console.ReadLine(); desktopRepo.Edit(newM); }
private void button4_Click(object sender, EventArgs e) { var mov = new MovieCreator { Title = textBox2.Text, Year = int.Parse(textBox3.Text), Genre = textBox5.Text, Type = textBox4.Text, Rating = int.Parse(textBox6.Text), Name = textBox7.Text }; desk.Add(mov); button2.BringToFront(); textBox2.Visible = false; label1.Visible = false; ChageVisible(false); listBox1.Items.Clear(); button1_Click(sender, e); }
private void button6_Click(object sender, EventArgs e) { var mov = new MovieCreator(); var x = listBox1.SelectedItem.ToString().Split('\t'); var i = x[1] == "" ? 2 : 1; mov.Title = x[0]; mov.Year = textBox3.Text == "" ? int.Parse(x[i]) : int.Parse(textBox3.Text); mov.Genre = textBox5.Text == "" ? x[i + 1] : textBox5.Text; mov.Type = textBox4.Text == "" ? x[i + 2] : textBox4.Text; mov.Rating = textBox6.Text == "" ? int.Parse(x[i + 3]) : int.Parse(textBox6.Text); mov.Name = textBox7.Text == "" ? x[i + 4] : textBox7.Text; desk.Edit(mov); button1_Click(sender, e); button5.Visible = false; button6.Visible = false; textBox2.Visible = false; label1.Visible = false; ChageVisible(false); }
private void Button_Add(object sender, RoutedEventArgs e) { var mov = new MovieCreator() { Title = Title.Text, Year = int.Parse(Year.Text), Genre = Genre.Text, Type = Type.Text, Rating = int.Parse(Rating.Text), Name = Name.Text }; desktopRepo.Add(mov); PAdd.Visibility = Visibility.Visible; Title.Visibility = Visibility.Hidden; TitleL.Visibility = Visibility.Hidden; ChangeVisible(Visibility.Hidden); ViewWindow.Items.Clear(); View_Click(sender, e); }
private void Edit_Click(object sender, RoutedEventArgs e) { var mov = new MovieCreator(); var x = ViewWindow.SelectedItem.ToString().Split('\t'); var i = x[1] == "" ? 2 : 1; mov.Title = x[0]; mov.Year = Year.Text == "" ? int.Parse(x[i]) : int.Parse(Year.Text); mov.Genre = Genre.Text == "" ? x[i + 1] : Genre.Text; mov.Type = Type.Text == "" ? x[i + 2] : Type.Text; mov.Rating = Rating.Text == "" ? int.Parse(x[i + 3]) : int.Parse(Rating.Text); mov.Name = Name.Text == "" ? x[i + 4] : Name.Text; desktopRepo.Edit(mov); View_Click(sender, e); Delete.Visibility = Visibility.Hidden; Edit.Visibility = Visibility.Hidden; Title.Visibility = Visibility.Hidden; TitleL.Visibility = Visibility.Hidden; ChangeVisible(Visibility.Hidden); }
public static StringContent CreateContent(Movie movie) { return(MovieCreator.Create(movie)); }
public void Put([FromBody] MovieCreator mov) { repo.EditMovie(mov); }
public async void Edit(MovieCreator mov) { var client = new HttpClient(); await client.PutAsJsonAsync($"http://moviedatabase.gear.host/api/Movies/{mov.Title}", mov); }
public ActionResult AddMovie(MovieShow model, string action, string person = null, string role = null, string genre = null, HttpPostedFileBase foto = null, HttpPostedFileBase poster = null) { MOVIEADVISOREntities6 entities = new MOVIEADVISOREntities6(); MovieCreator creator = new MovieCreator(); model = creator.update(model, action, foto, poster, Server, person, role, genre); List <SelectListItem> persons = new List <SelectListItem>(); List <SelectListItem> genres = new List <SelectListItem>(); List <SelectListItem> roles = new List <SelectListItem>(); List <PERSONS> tempPersonsHolder = entities.PERSONS.ToList(); foreach (var per in tempPersonsHolder) { bool isFree = true; foreach (var per1 in model.personsList) { if (per.ID == per1.person.ID) { isFree = false; } } if (isFree) { persons.Add(new SelectListItem() { Text = per.NAME, Value = per.ID.ToString() }); } } ViewBag.persons = persons.AsEnumerable(); List <GENRES> tempGenresHolder = entities.GENRES.ToList(); foreach (var gen in tempGenresHolder) { bool isFree = true; foreach (var gen1 in model.genres) { if (gen.ID == gen1.ID) { isFree = false; } } if (isFree) { genres.Add(new SelectListItem() { Text = gen.TITLE, Value = gen.ID.ToString() }); } } ViewBag.genres = genres.AsEnumerable(); List <ROLES> tempRolesHolder = entities.ROLES.ToList(); foreach (var rol in tempRolesHolder) { roles.Add(new SelectListItem() { Text = rol.TITLE, Value = rol.ID.ToString() }); } ViewBag.roles = roles.AsEnumerable(); if (action == "Сохранить") { return(RedirectToAction("New")); } return(View(model)); }
public HttpResponseMessage Post([FromBody] MovieCreator mov) { repo.AddMovie(mov); return(Request.CreateResponse(HttpStatusCode.Created)); }
public async void Add(MovieCreator mov) { var client = new HttpClient(); await client.PostAsJsonAsync("http://moviedatabase.gear.host/api/Movies", mov); }