public HttpResponseMessage DeleteReview( int id ) { CrudResult result = new CrudResult(); using ( Repo repo = new Repo() ) { result = repo.DeleteReview( id ); string json = JsonConvert.SerializeObject( result, jss ); HttpResponseMessage msg = Request.CreateResponse( HttpStatusCode.OK, json ); return msg; } }
public void ModelTest_DeleteReview() { // add review to guarantee a find Review r = new Review() { RestaurantId = 1, Comments = "This place is supr AWESOME!", Rating = 5, UserId = usr }; using ( SuprContext ctx = new SuprContext() ) { ctx.Review.Add( r ); ctx.SaveChanges(); // test the repository using ( Repo repo = new Repo() ) { CrudResult result = repo.DeleteReview( r.Id ); Assert.IsTrue( result.Success, "Review did not delete successfully." ); } } }