예제 #1
0
        public MainForm()
        {
            //TODO Add a splash screen while loading all this stuff (it could take a while
            //     with lots of actors, directors, or locations)
            //TODO Add an icon for the application and all resizable forms
            //TODO Implement sorting on all grids
            //TODO Move Domain and Models into their own assembly (MovieCollectionLib), so we
            //     can have multiple types of clients all using it
            //TODO Add linking table between Movie and Actor, so we can have multiple actors
            //     per movie, and update UI and all code to support this
            //TODO Make LocationsForm and ActorsDirectorsForm single instance
            Cursor          = Cursors.WaitCursor;
            _isInitialising = true;
            InitializeComponent();
            _actorDirectorGetter = new ActorDirectorGetter();
            _locationGetter      = new LocationGetter();
            _movieResultGetter   = new MovieResultGetter();
            _movieGetter         = new MovieGetter();
            _movieAdder          = new MovieAdder();

            RefreshActors();
            RefreshDirectors();
            RefreshLocations();
            _isInitialising = false;
            DoFilter(); //This will set the cursor back to default
        }
예제 #2
0
 public void ValidateForDelete(MovieGetter movieGetter)
 {
     if (movieGetter.IsExistingByLocationId(Id))
     {
         throw new LocationValidationException("At least one movie uses this location. Please move or remove " +
                                               "it and try again.");
     }
 }
예제 #3
0
 public LocationsForm(LocationGetter locationGetter, MovieGetter movieGetter)
 {
     Cursor = Cursors.WaitCursor;
     InitializeComponent();
     _locationAdder  = new LocationAdder();
     _locationGetter = locationGetter;
     _movieGetter    = movieGetter;
     RefreshData();
     Cursor = Cursors.Default;
 }
예제 #4
0
 public ActorsDirectorsForm(ActorDirectorGetter actorDirectorGetter,
                            MovieGetter movieGetter)
 {
     Cursor = Cursors.WaitCursor;
     InitializeComponent();
     _actorDirectorAdder  = new ActorDirectorAdder();
     _actorDirectorGetter = actorDirectorGetter;
     _movieGetter         = movieGetter;
     RefreshData();
     Cursor = Cursors.Default;
 }
예제 #5
0
 private void DoMovieChecks(bool checkForDirector, bool checkForActor, MovieGetter movieGetter)
 {
     if (checkForDirector && movieGetter.IsExistingByDirectorId(Id))
     {
         throw new ActorDirectorValidationException("At least one movie uses this director. Please move or remove " +
                                                    "it and try again.");
     }
     if (checkForActor && movieGetter.IsExistingByActorId(Id))
     {
         throw new ActorDirectorValidationException("At least one movie uses this actor. Please move or remove " +
                                                    "it and try again.");
     }
 }
예제 #6
0
        public void Validate(ActorDirectorGetter actorDirectorGetter, MovieGetter movieGetter)
        {
            if (string.IsNullOrWhiteSpace(Name))
            {
                throw new ActorDirectorValidationException("Name cannot be blank.");
            }
            if (!IsActor && !IsDirector)
            {
                throw new ActorDirectorValidationException("You must select either \"Is Actor\" or \"Is Director\" (or both)");
            }
            if (actorDirectorGetter.IsExistingByName(Name, Id))
            {
                throw new ActorDirectorValidationException(
                          $"An actor or director named {Name} already exists.");
            }

            DoMovieChecks(!IsDirector, !IsActor, movieGetter);
        }
예제 #7
0
        public AddUpdateActorDirectorForm(ActorDirector actorDirector,
                                          ActorDirectorGetter actorDirectorGetter, ActorDirectorAdder actorDirectorAdder,
                                          MovieGetter movieGetter)
        {
            InitializeComponent();
            _actorDirector        = actorDirector;
            _actorDirectorGetter  = actorDirectorGetter;
            _actorDirectorAdder   = actorDirectorAdder;
            _actorDirectorUpdater = new ActorDirectorUpdater();
            _movieGetter          = movieGetter;
            actorDirectorBindingSource.DataSource = _actorDirector;

            if (_actorDirector.IsNew)
            {
                base.Text = "Add Actor / Director";
            }
            else
            {
                base.Text = _actorDirector.Name;
            }
        }
예제 #8
0
 public void ValidateForDelete(MovieGetter movieGetter)
 {
     DoMovieChecks(IsDirector, IsActor, movieGetter);
 }
예제 #9
0
        private Task <List <Movie> > DefineTask(int imdbIdForTask, int batchSize)
        {
            Task <List <Movie> > task = Task <List <Movie> > .Run(() => MovieGetter.GetMovies(imdbIdForTask, batchSize));

            return(task);
        }