Beispiel #1
0
        //private static Func<int,Film> getFilmyById = i => new Film { Id = 1, Name = "Pulp Fiction", DirectorId = 1 };

        static RouteHandlers()
        {
            ListFilmsHandler = () => ListFilmsRoute.Handle();

            ListFilmByIdHandler = filmId => ListFilmByIdRoute.Handle(filmId,
                                                                     //Write some SQL to get the film
                                                                     fId => new Film {
                Id = 1, Name = "Pulp Fiction", DirectorId = 1
            },
                                                                     //Write some SQL to get the director
                                                                     dirId => new Director {
                Name = "Steven Spielberg"
            },
                                                                     //Write some SQL to get the cast
                                                                     fId => new[] { new CastMember {
                                                                                        Name = "John Travolta"
                                                                                    }, new CastMember {
                                                                                        Name = "Samuel L Jackson"
                                                                                    } }
                                                                     );

            UpdateFilmHandler = (filmId, film) => UpdateFilmRoute.Handle(
                filmId,
                film,
                () => new Random().Next() % 2 == 0,
                fId => new Film {
                Id = 1, Name = "Pulp Fiction", DirectorId = 1
            }
                );

            CreateFilmHandler = film => CreateFilmRoute.Handle(film, () => new Random().Next() % 2 == 0);

            DeleteFilmHandler = id => DeleteFilmRoute.Handle(id, () => new Random().Next() % 2 == 0);
        }
Beispiel #2
0
        static RouteHandlers()
        {
            CreateFilmHandler = film => CreateFilmRoute.Handle(film, () => ValidUserQuery.Execute());

            DeleteFilmHandler = id => DeleteFilmRoute.Handle(id, () => ValidUserQuery.Execute());

            ListFilmByIdHandler = id => ListFilmByIdRoute.Handle(
                id,
                filmId => ListFilmsByIdQuery.ListFilmsByIdQuery.Execute(id),
                dirId => GetDirectorByIdQuery.Execute(dirId),
                filmId => GetCastByFilmIdQuery.Execute(id)
                );

            ListFilmsHandler = () => ListFilmsRoute.Handle();

            UpdateFilmHandler = (id, film) => UpdateFilmRoute.Handle(
                id,
                film,
                () => ValidUserQuery.Execute(),
                filmId => ListFilmsByIdQuery.ListFilmsByIdQuery.Execute(filmId));
        }