public ActionResult AddMovie(AddMoviesModel _addMovie) { using (SinemaSitesiEntities db = new SinemaSitesiEntities()) { Movie x = new Movie(); x.Name = _addMovie.Name; x.Price = _addMovie.Price; x.Year = _addMovie.Year; x.Detail = _addMovie.Detail; x.AddedDate = DateTime.Now; db.Movie.Add(x); db.SaveChanges(); _addMovie.ID = db.Movie.OrderByDescending(t => t.ID).Select(t => t.ID).First(); MovieCategory y = new MovieCategory(); foreach (var item in _addMovie.CategoryIDs) { y.MovieID = _addMovie.ID; y.CategoryID = item; } db.MovieCategory.Add(y); db.SaveChanges(); } return(RedirectToAction("Movies", "Admin")); }
public Movie(string p1, MovieCategory movieCategory, int p2) { // TODO: Complete member initialization this.Name = p1; this.Category = movieCategory; this.Year = p2; }
public bool UpdateMovie(List <int> directorId, List <int> categoryId, Movie movie) { var directors = _movieContext.Directors.Where(d => directorId.Contains(d.Id)).ToList(); var categories = _movieContext.Categories.Where(c => categoryId.Contains(c.Id)).ToList(); var deleteMovieDirector = _movieContext.MovieDirectors.Where(md => md.MovieId == movie.Id); var deleteMovieCategory = _movieContext.MovieCategories.Where(mc => mc.MovieId == movie.Id); _movieContext.RemoveRange(deleteMovieDirector); _movieContext.RemoveRange(deleteMovieCategory); foreach (var director in directors) { var movieDirector = new MovieDirector() { Movie = movie, Director = director }; _movieContext.Add(movieDirector); } foreach (var category in categories) { var movieCategory = new MovieCategory() { Movie = movie, Category = category }; _movieContext.Add(movieCategory); } _movieContext.Update(movie); return(Save()); }
private async Task DownloadMovie(MovieCategory category, string movieName, string movieLink) { var movie = _moviesIndexerService.AddMovie(category, movieName); var context = BrowsingContext.New(Configuration.Default.WithDefaultLoader()); var document = await context.OpenAsync(_baseUrl + movieLink); var links = document.QuerySelectorAll(".dwnDesk.linkDown"); links.ToList().ForEach(async link => { var providerLink = link as IHtmlAnchorElement; var content = await _httpClient.GetStringAsync(providerLink.Href); var startIndex = content.IndexOf("window.location = '"); var videoLinkRaw = content.Substring(startIndex, content.IndexOf("';", startIndex)); videoLinkRaw = videoLinkRaw.Split("\n")[0]; var videoLink = videoLinkRaw.Replace("window.location = '", "").Replace("';", ""); if (videoLink.Contains("oload.site")) { videoLink = videoLink.Replace("oload.site", "openload.co"); } var videoUrl = new Url(videoLink); _moviesIndexerService.AddMovieLink(movie, videoUrl.HostName, videoLink); }); _logger.LogInformation($"Movie {movieName} ({category.Name}) indexed"); }
public ActionResult Edit(MovieViewModel movieVM) { var cat = _iCategory.GetCategoryList(); if (movieVM.MovieCategoryId != 0) { List <MovieCategory> mc = _iMovieCategory.GetMovieCategory(movieVM.ID); //var count = mc.Select(m => m.MovieCategoryId).Count(); foreach (var it in mc) { _iMovieCategory.Remove(it); } //for (var i = 0; i < count; i++) //{ // _iMovieCategory.Remove(mc.ElementAt(i)); // count--; //} } //var count = mc.Categories.Count; //for (var i = 0; i < count; i++) //{ // art.Categories.Remove(art.Categories.ElementAt(i)); // count--; //} if (ModelState.IsValid) { var movie = new Movie() { Title = movieVM.Title, ReleaseDate = movieVM.ReleaseDate, Genre = movieVM.Genre, Price = movieVM.Price, Description = movieVM.Description, Rating = movieVM.Rating, Barcode = movieVM.Barcode, ID = movieVM.ID }; int movieId = _iMovie.Update(movie); if (movieId != null) { foreach (var scat in movieVM.SelectedCat) { var movieCategory = new MovieCategory() { MovieId = movieId, CategoryId = scat }; _iMovie.InsertMovieCategory(movieCategory); } _iMovie.Commit(); } return(RedirectToAction("Index")); } ViewBag.CategoryList = _iCategory.GetCategoryList(); return(View(movieVM)); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync(string[] selectedCategories) { var newMovie = new Movie(); if (selectedCategories != null) { newMovie.MovieCategories = new List <MovieCategory>(); foreach (var cat in selectedCategories) { var catToAdd = new MovieCategory { CategoryID = int.Parse(cat) }; newMovie.MovieCategories.Add(catToAdd); } } if (await TryUpdateModelAsync <Movie>( newMovie, "Movie", i => i.Title, i => i.Director, i => i.Price, i => i.PublishingDate, i => i.CinemaID)) { _context.Movie.Add(newMovie); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } PopulateAssignedCategoryData(_context, newMovie); return(Page()); }
public void CreatingMovieAndCheckDefaultCategory() { var movie = new Movie(Session); Assert.IsNotNull(movie.Category); Assert.AreEqual(movie.Category, MovieCategory.GetDefaultCategory(Session)); }
protected void btnAddMovie_Click(object sender, EventArgs e) { MovieCategory movieCategory = new MovieCategory(); Movie movie = new Movie(); movie.Name = txtNameMovie.Text; movie.Writer = txtWriterMovie.Text; movie.Director = txtDirectorMovie.Text; movie.ImdbScore = Convert.ToDouble(txtImdb.Text); movie.Trailer = txtTrailerMovie.Text; movie.Summary = txtSummoryMovie.Text; movie.Year = DateTime.Parse(txtYearMovie.Text); movie.IsActive = checkIsActive.Checked; if (fileMoviePhoto.HasFile) { var fileName = fileMoviePhoto.FileName; FileInfo fileInfo = new FileInfo(fileName); var extension = fileInfo.Extension; var newFileName = $"{Guid.NewGuid()}{extension}"; string path = $"{Server.MapPath("~/Uploads")}/{newFileName}"; fileMoviePhoto.SaveAs(path); movie.CoverImage = newFileName; } _movieManager.Add(movie); movieCategory.CategoryId = Convert.ToInt32(listCategories.SelectedValue); movieCategory.MovieId = movie.Id; _movieCategory.Add(movieCategory); LoadListOfMovies(); Clear(); }
public void Bind (MovieCategory data, ConfigurationResponse configuration, Action<Movie> selectionAction) { this.category = data; this.configuration = configuration; this.selectionAction = selectionAction; this.lblCategoryName.Text = this.category.CategoryName; this.collectionViewSource = new MovieCollectionViewSource (this.category.Movies, this.configuration); this.collectionViewSource.MovieSelected += this.collectionViewSource_MovieSelected; Data.Current.FavoriteChanged += this.favoriteChanged; this.longPressRecognizer = new UILongPressGestureRecognizer (() => { if (this.longPressRecognizer.NumberOfTouches > 0) { var point = this.longPressRecognizer.LocationOfTouch (0, this.cvMovies); var indexPath = this.cvMovies.IndexPathForItemAtPoint (point); if (indexPath != null) { var cell = this.cvMovies.CellForItem (indexPath) as MovieCollectionViewCell; if (this.longPressRecognizer.State == UIGestureRecognizerState.Began) { cell.SetHighlighted (true, true); } else if (this.longPressRecognizer.State == UIGestureRecognizerState.Ended) { cell.SetHighlighted (false, true, () => { var movie = this.category.Movies [indexPath.Row]; Data.Current.ToggleFavorite (movie); }); } } else { foreach (MovieCollectionViewCell cell in this.cvMovies.VisibleCells) cell.SetHighlighted (false, false); } } }); this.cvMovies.AddGestureRecognizer (this.longPressRecognizer); this.cvMovies.Source = this.collectionViewSource; this.cvMovies.ReloadData (); }
//need Lis<int> as a paarameted as these list of ids coming from Uri public bool CreateMovie(List <int> directorId, List <int> categoryId, Movie movie) { //Movie enittiy model also has reeference to director & category model var directors = _movieContext.Directors.Where(d => directorId.Contains(d.Id)).ToList(); var categories = _movieContext.Categories.Where(c => categoryId.Contains(c.Id)).ToList(); foreach (var director in directors) { var movieDirector = new MovieDirector() { Movie = movie, Director = director }; _movieContext.Add(movieDirector); } foreach (var category in categories) { var movieCategory = new MovieCategory() { Movie = movie, Category = category }; _movieContext.Add(movieCategory); } _movieContext.Add(movie); return(Save()); }
public async Task <List <Movie> > ListMoviesByCategoryAsync(MovieCategory category) { int TotalNumberOfAttempts = 3; int numberOfAttempts = 0; while (true) { try { var url = UrlSuffixHelper(category); var jsonStr = await HttpGetCallAsync(url); var json = JsonConvert.DeserializeObject <JObject>(jsonStr); var movies = json["Movies"].ToObject <List <Movie> >(); return(movies); } catch { numberOfAttempts++; if (numberOfAttempts >= TotalNumberOfAttempts) { throw; } } } }
public async Task <Movie> FindMovieByCategoryByIdAsync(MovieCategory category, string Id) { int TotalNumberOfAttempts = 3; int numberOfAttempts = 0; while (true) { try { var url = UrlSuffixHelper(category, Id); var json = await HttpGetCallAsync(url); var movie = JsonConvert.DeserializeObject <Movie>(json); return(movie); } catch { numberOfAttempts++; if (numberOfAttempts >= TotalNumberOfAttempts) { throw; } } } }
public async Task <IActionResult> AddCategory(string categoryId) { var split = categoryId.Split(","); var idCategory = int.Parse(split[0]); var idMovie = int.Parse(split[1]); var movie = await _context.Movies.FirstOrDefaultAsync(m => m.Id == idMovie); var category = await _context.Categories.FirstOrDefaultAsync(m => m.Id == idCategory); var movieCategory = new MovieCategory() { CategoryId = idCategory, MovieId = idMovie, Category = category, Movie = movie }; var cat = _context.MovieCategories.FirstOrDefault(x => x.CategoryId == idCategory && x.MovieId == idMovie ); if (cat == null) { Console.WriteLine("contains"); movie.MovieCategories.Add(movieCategory); _context.Add(movieCategory); await _context.SaveChangesAsync(); } return(View("Details", movie)); //return RedirectToAction(nameof(Details)); }
public void CheckAnotherCategoriesList() { using (MovieCategoriesList categorieslist = (MovieCategoriesList)ModulesManager.Current.OpenModuleObjectDetail(new MovieCategoriesListObject(Session), false)) { MovieCategory editCategory = categorieslist.MovieCategoryEdit.MovieCategoryEditObject.VideoRentObject; Assert.IsTrue(categorieslist.MovieCategoryEdit.AnotherCategories.List.IndexOf(editCategory) < 0); } }
public static void SetMovieCategory <M, C, D>(M movie, C category, D db) where M : Movie where C : List <string> where D : ApplicationDbContext { if (category.Count() > 0) { //List<MovieCategory> _moviesCategories = new List<MovieCategory>(); /*var last_movie = db.Movies.ToArray(); * var _last_movie = last_movie[last_movie.Length - 1];*/ // var movie_id = _last_movie.Id; foreach (var id in category) { var _category = db.Categories.Find(int.Parse(id)); var _movieCategory = new MovieCategory() { Movie = movie, Category = _category }; db.MoviesCategories.Add(_movieCategory); //_moviesCategories.Add(_movieCategory); } /*if (_moviesCategories.Count()>0) { * db.MoviesCategories.AddRange(_moviesCategories); * }*/ } }
public void SaveMovieWithNullCategory() { var movie = new Movie(Session, "new film"); movie.Category = null; Session.CommitChanges(); Assert.AreEqual(MovieCategory.GetDefaultCategory(Session), movie.Category); }
public ActionResult DeleteConfirmed(int id) { MovieCategory movieCategory = db.MovieCategories.Find(id); db.MovieCategories.Remove(movieCategory); db.SaveChanges(); return(RedirectToAction("Index")); }
private void HwndTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { MovieCategory movie = (MovieCategory)HwndTree.SelectedItem; if (movie != null) { BindHwnd.Text = movie.Hwnd.ToString(); } }
public ActionResult DeleteConfirmed(int id) { MovieCategory movieCategory = db.MovieCategory.Find(id); movieCategory.Status = 2; db.Entry(movieCategory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Create a new MovieCategory object. /// </summary> /// <param name="id">Initial value of Id.</param> /// <param name="name">Initial value of Name.</param> /// <param name="position">Initial value of Position.</param> public static MovieCategory CreateMovieCategory(int id, string name, int position) { MovieCategory movieCategory = new MovieCategory(); movieCategory.Id = id; movieCategory.Name = name; movieCategory.Position = position; return(movieCategory); }
public ActionResult UpdateMovie([FromBody] MovieViewModel model) { Movie movieToSearch = dbHandler.Movies.Include(x => x.MovieCategories).FirstOrDefault(x => x.Id.ToString() == model.Id); if (movieToSearch is null) { return(BadRequest()); } if (model.Cover != movieToSearch.Cover && model.Cover.Length > 0) { DeleteImage(movieToSearch.Cover); movieToSearch.Cover = model.Cover; } movieToSearch.Name = (model.Name != movieToSearch.Name && model.Name.Length > 0) ? model.Name : movieToSearch.Name; movieToSearch.RecommendedAge = (model.RecommendedAge != movieToSearch.RecommendedAge && model.RecommendedAge != 0) ? model.RecommendedAge : movieToSearch.RecommendedAge; movieToSearch.Synopsis = (model.Synopsis != movieToSearch.Synopsis && model.Synopsis.Length > 0) ? model.Synopsis : movieToSearch.Synopsis; movieToSearch.Trailer = (model.Trailer != movieToSearch.Trailer && model.Trailer.Length > 0) ? model.Trailer : movieToSearch.Trailer; try { dbHandler.Movies.Update(movieToSearch); List <Category> CategoriesToIgnore = new List <Category>(); // Comproba si les categories que ja te asignades se l'has ha pasat el usuari en la llista, si no les esborra foreach (MovieCategory mc in movieToSearch.MovieCategories) { MovieCategory mc_db = dbHandler.MovieCategories.Include(x => x.Category).FirstOrDefault(x => x.Id == mc.Id); if (mc_db is null || model.Categories.Contains(mc_db.Category)) { CategoriesToIgnore.Add(mc_db.Category); continue; } dbHandler.MovieCategories.Remove(mc_db); } // Comproba que no es repeteixin categories si no hi ha de repetides afageix les noves afegides en la llista foreach (Category category in model.Categories) { Category is_in_db = dbHandler.Categories.FirstOrDefault(x => x.Id == category.Id); if (is_in_db is null || CategoriesToIgnore.Contains(is_in_db)) { continue; } MovieCategory movieCategory = new MovieCategory { Category = is_in_db, Movie = movieToSearch }; movieToSearch.MovieCategories.Add(movieCategory); } dbHandler.SaveChanges(); } catch (Exception) { return(BadRequest()); } return(Ok()); }
public ActionResult Edit([Bind(Include = "CategoryId,CategoryName")] MovieCategory movieCategory) { if (ModelState.IsValid) { db.Entry(movieCategory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(movieCategory)); }
public void OpenCategoriesList_Dispose_SendSetUpdated() { Guid categoryOid = new MovieCategory(Session).Oid; SessionHelper.CommitSession(Session, null); MovieCategoriesList categorieslist = (MovieCategoriesList)ModulesManager.Current.OpenModuleObjectDetail(new MovieCategoriesListObject(Session), false); categorieslist.Dispose(); AllObjects <MovieCategory> .Set.RaiseUpdated(new TestEditableObject(categoryOid)); }
private void listparkCountryCategories2_SelectionChanged(object sender, SelectionChangedEventArgs e) { MovieCategory movieCategory = this.listparkCountryCategories2.SelectedItem as MovieCategory; if (!(movieCategory.Url != this.Ca)) { return; } this.Ca = movieCategory.Url; App.ViewModel.LoadTVHot(this.Ca); }
public ActionResult Create([Bind(Include = "CategoryId,CategoryName")] MovieCategory movieCategory) { if (ModelState.IsValid) { db.MovieCategories.Add(movieCategory); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(movieCategory)); }
public bool Save(MovieCategory obj, ref string message) { if (obj.Id == 0) { return(Add(obj, ref message)); } else { return(Update(obj.Id, obj)); } }
public ActionResult Create([FromBody] MovieViewModel model) { string Email = User.FindFirstValue(ClaimTypes.Email); if (Email is null) { return(BadRequest()); } User user = dbHandler.Users.FirstOrDefault(x => x.Email == Email); if (user is null) { return(BadRequest()); } try { float Rating = GetRating(model); Movie movie = new Movie { Name = model.Name, RecommendedAge = model.RecommendedAge, Synopsis = model.Synopsis, Trailer = model.Trailer, Cover = model.Cover, Owner = user, Rating = Rating }; dbHandler.Movies.Add(movie); if (model.Categories.Count > 0) { foreach (Category category in model.Categories) { Category is_in_db = dbHandler.Categories.FirstOrDefault(x => x.Id == category.Id); if (is_in_db is null) { continue; } MovieCategory movieCategory = new MovieCategory { Category = is_in_db, Movie = movie }; movie.MovieCategories.Add(movieCategory); } } dbHandler.SaveChanges(); } catch (Exception) { return(BadRequest(Message.GetMessage("Hi ha hagut un error al intentar afegir la película"))); } return(Ok()); }
public void UpdateBlogCategory(MovieCategory blogCategory) { var bc = GetBlogCategory(blogCategory.CategoryID); bc.CategoryName = blogCategory.CategoryName; bc.PageTitle = blogCategory.PageTitle; bc.MetaDescription = blogCategory.MetaDescription; bc.MetaKeywords = blogCategory.MetaKeywords; bc.SortOrder = blogCategory.SortOrder; db.SaveChanges(); }
private void listparkCountryCategories2_SelectionChanged(object sender, SelectionChangedEventArgs e) { MovieCategory movieCategory = this.listparkCountryCategories2.SelectedItem as MovieCategory; if (!(movieCategory.Url != this.ca)) { return; } this.ca = movieCategory.Url; this._pageNum = 1; App.ViewModel.LoadMovie(this._urlPage, this._pageNum, this.ca, type); }
private void EnumWindows(int parentHwd, MovieCategory movieCategory) { string[] hwnds = DM.EnumWindow(parentHwd, "", "", 4).Split(','); for (int i = 0; i < hwnds.Length; i++) { if (hwnds[i].Trim() != "") { int hwnd = int.Parse(hwnds[i].Trim()); movieCategory.Movies.Add(new MovieCategory(hwnd, DM.GetWindowTitle(hwnd), DM.GetWindowClass(hwnd))); EnumWindows(hwnd, movieCategory.Movies[i]); } } }
public bool Remove(MovieCategory obj) { bool state = false; uow.MovieCategories.Remove(obj); int result = uow.Complete(); if (result > 0) { state = true; } return(state); }
public override void PrepareForReuse () { if (this.collectionViewSource != null) this.collectionViewSource.MovieSelected -= this.collectionViewSource_MovieSelected; Data.Current.FavoriteChanged -= this.favoriteChanged; this.collectionViewSource = null; this.category = null; this.configuration = null; this.selectionAction = null; this.cvMovies.RemoveGestureRecognizer (this.longPressRecognizer); this.longPressRecognizer = null; base.PrepareForReuse (); }
/// <summary> /// There are no comments for MovieCategorySet in the schema. /// </summary> public void AddToMovieCategorySet(MovieCategory movieCategory) { base.AddObject("MovieCategorySet", movieCategory); }
/// <summary> /// Create a new MovieCategory object. /// </summary> /// <param name="id">Initial value of Id.</param> /// <param name="name">Initial value of Name.</param> /// <param name="position">Initial value of Position.</param> public static MovieCategory CreateMovieCategory(int id, string name, int position) { MovieCategory movieCategory = new MovieCategory(); movieCategory.Id = id; movieCategory.Name = name; movieCategory.Position = position; return movieCategory; }