Ejemplo n.º 1
0
		public HttpResponseMessage GetRestaurant( string city ) {
			using ( Repo repo = new Repo() ) {
				ListResult<Restaurant> result = repo.GetRestaurantsByCity( city );
				string json = JsonConvert.SerializeObject( result, jss );
				HttpResponseMessage msg = Request.CreateResponse( HttpStatusCode.OK, json );
				return msg;
			}
		}
Ejemplo n.º 2
0
		public void ModelTest_GetRestaurantByCity() {
			// add restaurant to guarantee a find
			Restaurant r = new Restaurant() { Name = "Testaurant", City = "butLEr", State = "PA" };
			using ( SuprContext ctx = new SuprContext() ) {
				ctx.Restaurant.Add( r );
				ctx.SaveChanges();

				// test the repository
				string city = "BUtler";
				using ( Repo repo = new Repo() ) {
					ListResult<Restaurant> restaurants = repo.GetRestaurantsByCity( city );
					Assert.IsNotNull( restaurants, "No restaurants in " + city + " found." );
				}

				// delete the created restaurant
				r = ctx.Restaurant.Where( d => d.Id == r.Id ).First();
				ctx.Restaurant.Remove( r );
				ctx.SaveChanges();
			}
		}