public void TestListMealAsync() { RestaurantSeeder.Seed(); var bo = new MealBusinessObject(); var resList = bo.ListAsync().Result; Assert.IsTrue(resList.Success && resList.Result.Count > 0); }
public void TestListMealAsync() { ContextSeeders.Seed(); var bo = new MealBusinessObject(); var resList = bo.ListAsync().Result; Assert.IsTrue(resList.Success && resList.Result.Count == 1); }
public void TestDeleteMealAsync() { RestaurantSeeder.SeedCountries(); var bo = new MealBusinessObject(); var resList = bo.ListAsync().Result; var resDelete = bo.DeleteAsync(resList.Result.First().Id).Result; var resNotList = bo.ListUnDeletedAsync().Result; Assert.IsTrue(resDelete.Success && resNotList.Result.Count == 0); }
public void TestDeleteMealAsync() { RestaurantSeeder.Seed(); var bo = new MealBusinessObject(); var resList = bo.ListAsync().Result; var total = resList.Result.Count; var resDelete = bo.DeleteAsync(resList.Result.First().Id).Result; resList = bo.ListNonDeletedAsync().Result; Assert.IsTrue(resDelete.Success && resList.Success && resList.Result.Count == total - 1); }
public void TestDeleteMealAsync() { ContextSeeders.Seed(); var bo = new MealBusinessObject(); var resList = bo.List(); var resDelete = bo.DeleteAsync(resList.Result.First().Id).Result; resList = bo.ListAsync().Result; Assert.IsTrue(resDelete.Success && resList.Success && resList.Result.First().IsDeleted); }
public void TestUpdateMealAsync() { RestaurantSeeder.Seed(); var bo = new MealBusinessObject(); var resList = bo.ListAsync().Result; var item = resList.Result.FirstOrDefault(); item.Name = "another"; var resUpdate = bo.UpdateAsync(item).Result; resList = bo.ListNonDeletedAsync().Result; Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().Name == "another"); }
public void TestUpdateMealAsync() { RestaurantSeeder.SeedCountries(); var bo = new MealBusinessObject(); var resList = bo.ListAsync().Result; var item = resList.Result.FirstOrDefault(); item.StartingHours = "20h00"; var resUpdate = bo.UpdateAsync(item).Result; var resNotList = bo.ListUnDeletedAsync().Result; Assert.IsTrue(resUpdate.Success && resNotList.Result.First().StartingHours == "20h00"); }
public void TestCreateAndListMenuAsync() { RestaurantSeeder.Seed(); var mbo = new MealBusinessObject(); var rbo = new RestaurantBusinessObject(); var mebo = new MenuBusinessObject(); var m = mbo.ListAsync().Result.Result.First(); var r = rbo.ListAsync().Result.Result.First(); var dr = new Menu(DateTime.Now, r.Id, m.Id); var resCreate = mebo.CreateAsync(dr).Result; var resGet = mebo.ReadAsync(dr.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public void TestUpdateMealAsync() { ContextSeeders.Seed(); var mbo = new MealBusinessObject(); var resList = mbo.List(); var item = resList.Result.FirstOrDefault(); var newMeal = new Meal("lasagna", "8pm", "10pm"); item.Name = newMeal.Name; item.StartingHours = newMeal.StartingHours; item.EndingHours = newMeal.EndingHours; var resUpdate = mbo.UpdateAsync(item).Result; resList = mbo.ListAsync().Result; Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().Name == newMeal.Name && resList.Result.First().StartingHours == newMeal.StartingHours && resList.Result.First().EndingHours == newMeal.EndingHours); }
public async Task <IActionResult> Index() { var listOperation = await _bo.ListAsync(); if (!listOperation.Success) { return(View("Error", new ErrorViewModel() { RequestId = listOperation.Exception.Message })); } var lst = new List <MealViewModel>(); foreach (var item in listOperation.Result) { if (!item.IsDeleted) { lst.Add(MealViewModel.Parse(item)); } } return(View(lst)); }
public async Task <IActionResult> Index() { var menuOfTheDay = new MenuOfTheDayViewModel(); var menuListOperation = await _menubo.ListAsync(); if (!menuListOperation.Success) { return(View("Error")); } if (menuListOperation.Result.Count == 0) { return(View("Error")); } var servingListOperation = await _sbo.ListAsync(); if (!servingListOperation.Success) { return(View("Error")); } if (servingListOperation.Result.Count == 0) { return(View("Error")); } var dishListOperation = await _dbo.ListAsync(); if (!dishListOperation.Success) { return(View("Error")); } if (dishListOperation.Result.Count == 0) { return(View("Error")); } var dietaryRestrictionListOperation = await _drbo.ListAsync(); if (!dietaryRestrictionListOperation.Success) { return(View("Error")); } if (dietaryRestrictionListOperation.Result.Count == 0) { return(View("Error")); } var mealListOperation = await _mealbo.ListAsync(); if (!mealListOperation.Success) { return(View("Error")); } if (mealListOperation.Result.Count == 0) { return(View("Error")); } var courseListOperation = await _cbo.ListAsync(); if (!courseListOperation.Success) { return(View("Error")); } if (courseListOperation.Result.Count == 0) { return(View("Error")); } foreach (var serving in servingListOperation.Result) { var course = courseListOperation.Result.First(x => x.Id == serving.CourseId); var dish = dishListOperation.Result.First(x => x.Id == serving.DishId); var menu = menuListOperation.Result.First(x => x.Id == serving.MenuId); var dr = dietaryRestrictionListOperation.Result.First(x => x.Id == dish.DietaryRestrictionId); var meal = mealListOperation.Result.First(x => x.Id == menu.MealId); if (meal.Menus == null) { meal.Menus = new List <Menu>(); } meal.Menus.Add(menu); menu.Meal = meal; if (menu.Servings == null) { menu.Servings = new List <Serving>(); } menu.Servings.Add(serving); serving.Menu = menu; if (dr.Dishes == null) { dr.Dishes = new List <Dish>(); } dr.Dishes.Add(dish); dish.DietaryRestriction = dr; if (dish.Servings == null) { dish.Servings = new List <Serving>(); } dish.Servings.Add(serving); serving.Dish = dish; if (course.Servings == null) { course.Servings = new List <Serving>(); } course.Servings.Add(serving); serving.Course = course; } List <ItemOnMenuOfTheDayViewModel> items = new List <ItemOnMenuOfTheDayViewModel>(); foreach (var dr in dietaryRestrictionListOperation.Result) { var drvm = DietaryRestrictionViewModel.Parse(dr); foreach (var dish in dr.Dishes) { var dishvm = DishViewModel.Parse(dish); items.Add(new ItemOnMenuOfTheDayViewModel() { DietaryRestriction = drvm, Dish = dishvm }); } } return(View(menuOfTheDay)); }