public IActionResult GetMealTypeById(int id)
        {
            var result = mealTypeUC.GetMealTypeById(id);

            if (result != null)
            {
                return(View(result));
            }
            else
            {
                return(RedirectToAction("Error", new { errorMessage = "Sorry! We don't find this Meal Type" }));
            }
        }
Exemplo n.º 2
0
        public IActionResult GetBasketsByUserId()
        {
            var          result  = basketUC.GetBasketsByUserId(User.FindFirst(ClaimTypes.NameIdentifier).Value).ToList();
            RestaurantUC restoUC = new RestaurantUC(restoRepository);

            foreach (var item in result)
            {
                foreach (var shoppingMeal in item.ShoppingMeals)
                {
                    shoppingMeal.Meal.MealType            = mealTypeUC.GetMealTypeById(shoppingMeal.Meal.MealTypeID);
                    shoppingMeal.Meal.MealType.Restaurant = restoUC.GetRestaurantById(shoppingMeal.Meal.MealType.RestaurantId);
                }
            }
            result = result.OrderBy(x => x.ArrivalDate).ToList();
            return(View(result));
        }
Exemplo n.º 3
0
        public void GetMealTypeById_Should_Return_Valid_Data()
        {
            //Arrange
            var mock       = new Mock <IMealTypeRepository>();
            var myMealType = new MealTypeDTO
            {
                Id         = 1,
                Name       = "Starter",
                Restaurant = new RestoDTO()
            };

            mock.Setup(x => x.GetById(1)).Returns(
                new MealTypeDTO
            {
                Id         = 1,
                Name       = "Starter",
                Restaurant = new RestoDTO()
            }
                );

            MealTypeUC target = new MealTypeUC(mock.Object);

            //Act
            var result = target.GetMealTypeById(1);

            //Assert
            Assert.AreEqual(result.Id, 1);
            Assert.AreEqual(result.Name, "Starter");
        }
Exemplo n.º 4
0
        public void GetMealTypeById_Should_Return_Null_When_Not_Found()
        {
            //Arrange
            var mock = new Mock <IMealTypeRepository>();

            mock.Setup(x => x.GetById(25));
            MealTypeUC target = new MealTypeUC(mock.Object);

            //Act
            var result = target.GetMealTypeById(25);

            //Assert
            Assert.AreEqual(null, result);
            Assert.IsNull(result);
        }