protected void Page_Load(object sender, EventArgs e) { RatingManager manager = new RatingManager(); AllRatings = manager.GetAll(); if (!IsPostBack) { DoDataBind(); } else { AllRatings = manager.GetAll(); } manager.Dispose(); }
public IActionResult List(string name, string surname, string course) { var model = RatingManager.GetAll().Select(i => i.ToModel()).ToList(); model = model.Where(i => i.Student.Name == name && i.Student.Surname == surname || i.Course.Course == course).ToList(); return(View(model)); }
public ActionResult Create(int?theaterId) { var model = new MovieViewModel(); if (theaterId.HasValue) { model.Theater = TheaterManager.GetByTheaterId(theaterId.Value); } var allRatings = RatingManager.GetAll(); var allGenres = GenreManager.GetAll(); var checkBoxListItems = new List <CheckBoxListItem>(); model.Ratings = allRatings; foreach (var genre in allGenres) { checkBoxListItems.Add(new CheckBoxListItem() { ID = genre.GenreId, Display = genre.GenreName, IsChecked = false // On the add view, no genres will be selected by default }); } model.Genres = checkBoxListItems; ViewBag.AvailableTheaters = TheaterManager.GetAll(); return(View(model)); }
public ActionResult Edit(int id) { var model = MovieManager.GetById(id); var allRatings = RatingManager.GetAll(); var movieGenres = GenreManager.GetForMovie(id); var allGenres = GenreManager.GetAll(); var checkBoxListItems = new List <CheckBoxListItem>(); foreach (var genre in allGenres) { checkBoxListItems.Add(new CheckBoxListItem() { ID = genre.GenreId, Display = genre.GenreName, IsChecked = movieGenres.Any(x => x.GenreId == genre.GenreId) }); } model.Ratings = allRatings; model.Genres = checkBoxListItems; return(View(model)); }
protected void Page_Load(object sender, EventArgs e) { RatingManager ratingManager = new RatingManager(); RatingDropDownList.DataValueField = "Id"; RatingDropDownList.DataTextField = "Description"; RatingDropDownList.DataSource = ratingManager.GetAll(); RatingDropDownList.DataBind(); }
public void GetAll_AllRatingsReturned_ExpectedCountEqualAcual() { using (RatingManager ratingManger = new RatingManager(new BrothershipUnitOfWork(DataContextCreator.CreateTestContext()))) { const int expectedCount = 5; int actualCount = ratingManger.GetAll().Count; Assert.AreEqual(expectedCount, actualCount); } }
public ActionResult Index() { List <Rating> ratings; using (manager = new RatingManager()) { ratings = manager.GetAll(); } return(View(ratings)); }
private void DoDataBind() { RatingManager manager = new RatingManager(); RatingDropDownList.DataValueField = "Id"; RatingDropDownList.DataTextField = "Description"; RatingDropDownList.DataSource = manager.GetAll(); RatingDropDownList.DataBind(); UpdateTextBoxes(); manager.Dispose(); }
private void UpdateTextBoxes() { RatingManager manager = new RatingManager(); AllRatings = manager.GetAll(); if (AllRatings.Count > 0) { int index = RatingDropDownList.SelectedIndex; var selectedRating = AllRatings[index]; RatingTextBox.Text = selectedRating.Description; } }
public ActionResult Create() { MovieViewModel viewModel = new MovieViewModel(); viewModel.Movie = new Movie(); using (GenreManager genreManager = new GenreManager()) { viewModel.PossibleGenres = genreManager.GetAll(); } using (RatingManager ratingManager = new RatingManager()) { viewModel.PossibleRatings = ratingManager.GetAll(); } using (DirectorManager directorManager = new DirectorManager()) { viewModel.PossibleDirectors = directorManager.GetAll(); } using (FormatManager formatManager = new FormatManager()) { viewModel.PossibleFormats = formatManager.GetAll(); } return(View(viewModel)); }
public IActionResult Index() { var model = RatingManager.GetAll().Select(i => i.ToModel()).ToList(); return(View(model)); }
public void Get_All_Returns_More_Than_One() { var all = manager.GetAll(); Assert.IsTrue(all.Count > 1); }
public ActionResult Edit(int id) { Movie movie = new Movie(); using (manager = new MovieManager()) { movie = manager.GetById(id); } if (movie == null) { return(HttpNotFound()); } else { MovieViewModel vm = new MovieViewModel(); using (GenreManager genreManager = new GenreManager()) { vm.PossibleGenres = genreManager.GetAll(); } using (RatingManager ratingManager = new RatingManager()) { vm.PossibleRatings = ratingManager.GetAll(); } using (DirectorManager directorManager = new DirectorManager()) { vm.PossibleDirectors = directorManager.GetAll(); } using (FormatManager formatManager = new FormatManager()) { vm.PossibleFormats = formatManager.GetAll(); } //vm.MovieId = movie.Id; vm.Movie = movie; vm.MovieDescription = movie.Description; vm.MovieCost = movie.Cost; vm.MovieTitle = movie.Title; vm.ImagePath = movie.ImagePath; vm.CurrentGenres = new List <int>(); foreach (var a in movie.Genres) { vm.CurrentGenres.Add(a.Id); } return(View(vm)); } }