Example #1
0
        /// <summary>Determines whether the specified <see cref="T:System.Object" /> is equal to the current <see cref="T:System.Object" />.</summary>
        ///
        /// <param name="other">The movie to compare to this object.</param>
        ///
        /// <returns>true if the specified <see cref="T:System.Object" /> is equal to the current <see cref="T:System.Object" />; otherwise, false.</returns>
		public bool Equals(Movie other)
		{
			if (ReferenceEquals(null, other)) return false;
			if (ReferenceEquals(this, other)) return true;
			return Equals(other.ImdbId, ImdbId)
				&& Equals(other.Title, Title)
				&& other.Rating == Rating
				&& Equals(other.Director, Director)
				&& other.ReleaseDate.Equals(ReleaseDate)
				&& Equals(other.TagLine, TagLine)
				&& Genres.EquivalentTo(other.Genres);
		}
Example #2
0
		public void Can_PATCH_Movie_from_dto()
		{
			ExecutePath(HttpMethods.Post, "/movies", null, null, NewMovie);

			var lastInsertId = (int)this.DbFactory.Run(db => db.GetLastInsertId());

			var patchMovie = new Movie { Id = lastInsertId, Title = "PATCHED " + NewMovie.Title };
			ExecutePath(HttpMethods.Patch, "/movies", null, null, patchMovie);

			this.DbFactory.Run(db => {
				var movie = db.GetById<Movie>(lastInsertId);
				Assert.That(movie, Is.Not.Null);
				Assert.That(movie.Title, Is.EqualTo(patchMovie.Title));
			});
		}
Example #3
0
		/// <summary>
		/// PATCH /movies
		/// </summary>
		public object Patch(Movie movie)
		{
            var existingMovie = Db.GetById<Movie>(movie.Id);
            if (movie.Title != null)
                existingMovie.Title = movie.Title;
            Db.Save(existingMovie);
            
            return new MovieResponse();
		}
Example #4
0
		/// <summary>
		/// DELETE /movies/{Id}
		/// </summary>
		public object Delete(Movie request)
		{
			Db.DeleteById<Movie>(request.Id);
			return new MovieResponse();
		}
Example #5
0
		/// <summary>
		/// PUT /movies
		/// </summary>
		public object Put(Movie movie)
		{
		    Db.Update(movie);
			return new MovieResponse();
		}
Example #6
0
		/// <summary>
		/// POST /movies
		/// </summary>
		public object Post(Movie movie)
		{
            Db.Insert(movie);
			var newMovieId = Db.GetLastInsertId();

			var newMovie = new MovieResponse {
				Movie = Db.GetById<Movie>(newMovieId)
			};
			return new HttpResult(newMovie) {
				StatusCode = HttpStatusCode.Created,
				Headers = {
					{ HttpHeaders.Location, this.RequestContext.AbsoluteUri.WithTrailingSlash() + newMovieId }
				}
			};
		}
Example #7
0
		/// <summary>
		/// GET /movies/{Id} 
		/// </summary>
		public object Get(Movie movie)
		{
			return new MovieResponse {
				Movie = Db.GetById<Movie>(movie.Id)
			};
		}