public ActionResult Create([FromBody] MealViewModel vm)
        {
            var rt  = vm.ToMeal();
            var res = _bo.Create(rt);

            return(res.Success ? Ok() : InternalServerError());
        }
Пример #2
0
        public void TestUpdateMenu()
        {
            ContextSeeders.Seed();
            var mbo     = new MenuBusinessObject();
            var resList = mbo.List();
            var item    = resList.Result.FirstOrDefault();

            var rbo    = new RestaurantBusinessObject();
            var mealbo = new MealBusinessObject();

            var restaurant = new Restaurant("a", "b", "c", "d", "f", 6);
            var meal       = new Meal("a", "b", "c");

            rbo.Create(restaurant);
            mealbo.Create(meal);

            var newMenu = new Menu(DateTime.Now, restaurant.Id, meal.Id);

            item.Date         = newMenu.Date;
            item.RestaurantId = newMenu.RestaurantId;
            item.MealId       = newMenu.MealId;

            var resUpdate = mbo.Update(item);

            resList = mbo.List();

            Assert.IsTrue(resList.Success && resUpdate.Success &&
                          resList.Result.First().Date == newMenu.Date && resList.Result.First().RestaurantId == newMenu.RestaurantId &&
                          resList.Result.First().MealId == newMenu.MealId);
        }
Пример #3
0
            public void TestCreateServingAsync()
            {
                ContextSeeders.Seed();
                var sbo = new ServingBusinessObject();

                var rbo    = new RestaurantBusinessObject();
                var mealbo = new MealBusinessObject();
                var drbo   = new DietaryRestrictionBusinessObject();
                var mbo    = new MenuBusinessObject();
                var cbo    = new CourseBusinessObject();
                var dbo    = new DishBusinessObject();

                var restaurant = new Restaurant("a", "b", "c", "d", "f", 6);
                var meal       = new Meal("a", "b", "c");
                var dr         = new DietaryRestriction("ok");
                var menu       = new Menu(DateTime.Now, restaurant.Id, meal.Id);
                var course     = new Course("yes");
                var dish       = new Dish("uh", dr.Id);

                rbo.Create(restaurant);
                mealbo.Create(meal);
                drbo.Create(dr);
                mbo.Create(menu);
                cbo.Create(course);
                dbo.Create(dish);

                var serving = new Serving(menu.Id, course.Id, dish.Id);

                var resCreate = sbo.CreateAsync(serving).Result;
                var resGet    = sbo.ReadAsync(serving.Id).Result;

                Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
            }
Пример #4
0
        public ActionResult Create([FromBody] MealViewModel vm)
        {
            var m    = new Meal(vm.Name, vm.Starting, vm.Ending);
            var res  = _bo.Create(m);
            var code = res.Success ? Ok() : StatusCode((int)HttpStatusCode.InternalServerError);

            return(new ObjectResult(code));
        }
Пример #5
0
        public void TestCreateAndListMeal()
        {
            RestaurantSeeder.Seed();
            var bo        = new MealBusinessObject();
            var dr        = new Meal("Vegetarian", "19", "20");
            var resCreate = bo.Create(dr);
            var resGet    = bo.Read(dr.Id);

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
Пример #6
0
        public void TestCreateMeal()
        {
            ContextSeeders.Seed();
            var mbo = new MealBusinessObject();

            var meal      = new Meal("pizza", "7pm", "11pm");
            var resCreate = mbo.Create(meal);
            var resGet    = mbo.Read(meal.Id);

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
Пример #7
0
        public void TestCreateAndReadMeal()
        {
            RestaurantSeeder.SeedCountries();
            var bo = new MealBusinessObject();

            var meal = new Meal("Dinner", "19h00", "23h00");

            var resCreate = bo.Create(meal);
            var resGet    = bo.Read(meal.Id);

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
Пример #8
0
            public void TestUpdateServingAsync()
            {
                ContextSeeders.Seed();
                var sbo     = new ServingBusinessObject();
                var resList = sbo.List();
                var item    = resList.Result.FirstOrDefault();

                var rbo    = new RestaurantBusinessObject();
                var mealbo = new MealBusinessObject();
                var drbo   = new DietaryRestrictionBusinessObject();
                var mbo    = new MenuBusinessObject();
                var cbo    = new CourseBusinessObject();
                var dbo    = new DishBusinessObject();

                var restaurant = new Restaurant("a", "b", "c", "d", "f", 6);
                var meal       = new Meal("a", "b", "c");
                var dr         = new DietaryRestriction("ok");
                var menu       = new Menu(DateTime.Now, restaurant.Id, meal.Id);
                var course     = new Course("yes");
                var dish       = new Dish("uh", dr.Id);

                rbo.Create(restaurant);
                mealbo.Create(meal);
                drbo.Create(dr);
                mbo.Create(menu);
                cbo.Create(course);
                dbo.Create(dish);

                var newServing = new Serving(menu.Id, course.Id, dish.Id);

                item.MenuId   = newServing.MenuId;
                item.CourseId = newServing.CourseId;
                item.DishId   = newServing.DishId;

                var resUpdate = sbo.UpdateAsync(item).Result;

                resList = sbo.ListAsync().Result;

                Assert.IsTrue(resList.Success && resUpdate.Success &&
                              resList.Result.First().MenuId == newServing.MenuId && resList.Result.First().CourseId == newServing.CourseId &&
                              resList.Result.First().DishId == newServing.DishId);
            }
Пример #9
0
        public void TestCreateMenuAsync()
        {
            ContextSeeders.Seed();
            var mbo = new MenuBusinessObject();

            var rbo    = new RestaurantBusinessObject();
            var mealbo = new MealBusinessObject();

            var restaurant = new Restaurant("a", "b", "c", "d", "f", 6);
            var meal       = new Meal("a", "b", "c");

            rbo.Create(restaurant);
            mealbo.Create(meal);

            var menu = new Menu(DateTime.Now, restaurant.Id, meal.Id);

            var resCreate = mbo.CreateAsync(menu).Result;
            var resGet    = mbo.ReadAsync(menu.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }