public void Edit_ShouldReturn400BadRequestWhenModelIsNull() { var context = new RestaurantsContext(); var newTown = new Town() { Name = "New town" }; context.Towns.Add(newTown); context.SaveChanges(); var newRestaurant = new Restaurant() { Name = "New restaurant", TownId = newTown.Id }; context.Restaurants.Add(newRestaurant); context.SaveChanges(); var newMeal = new Meal() { Name = "New meal", Price = 4.99M, RestaurantId = newRestaurant.Id, TypeId = 3 }; context.Meals.Add(newMeal); context.SaveChanges(); var content = new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>("name", "aaaaa") }); var response = httpClient.PutAsync(string.Format("api/meals/{0}", newMeal.Id), content).Result; Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); }
public async Task<bool> SaveMeal(Meal meal) { if (await this.dataLayer.AddMeal(meal)) { await LoadMeals(); return true; } return false; }
public void Eat(Meal meal) { Meals.Add(meal); }
public void Initialize() { pie = new Meal("Pie"); glassOfMilk = new Meal("Glass of milk", milkAsIngredient, 100); largeGlassOfMilk = new Meal("Glass of milk", milkAsIngredient, 250); }
private void SeedMeal() { using (var context = new RestaurantsContext()) { var newMeal = new Meal() { Name = "New meal", Price = 4.99M, RestaurantId = restaurantId, TypeId = firstMealTypeId }; context.Meals.Add(newMeal); context.SaveChanges(); this.mealId = newMeal.Id; } }