public ActionResult Create([FromBody] DishViewModel vm)
        {
            var d   = vm.ToDish();
            var res = _bo.Create(d);

            return(StatusCode(res.Success ? (int)HttpStatusCode.OK : (int)HttpStatusCode.InternalServerError));
        }
示例#2
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);
            }
        public ActionResult Create([FromBody] DishViewModel vm)
        {
            var rt  = vm.ToDish();
            var res = _bo.Create(rt);

            return(res.Success ? Ok() : InternalServerError());
        }
        public ActionResult Create([FromBody] DishViewModel vm)
        {
            var dr = new Dish(vm.Name, vm.DietaryRestrictionId);

            var res  = _bo.Create(dr);
            var code = res.Success ? HttpStatusCode.OK : HttpStatusCode.InternalServerError;

            return(new ObjectResult(code));
        }
示例#5
0
        public void TestCreateAndListDish()
        {
            RestaurantSeeder.Seed();
            var dbo  = new DishBusinessObject();
            var drbo = new DietaryRestrictionBusinessObject();
            var firstDietaryRestriction = drbo.List().Result.First();
            var dr        = new Dish("Vegetarian", firstDietaryRestriction.Id);
            var resCreate = dbo.Create(dr);
            var resGet    = dbo.Read(dr.Id);

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
示例#6
0
        public void TestCreateAndReadDish()
        {
            RestaurantSeeder.SeedCountries();
            var bo        = new DishBusinessObject();
            var boForeign = new DietaryRestrictionBusinessObject();

            var dish = new Dish("Lasagne", boForeign.List().Result.First().Id);

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

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
示例#7
0
        public void TestCreateDish()
        {
            ContextSeeders.Seed();
            var drbo = new DietaryRestrictionBusinessObject();
            var dbo  = new DishBusinessObject();

            var dr   = new DietaryRestriction("vegan");
            var dish = new Dish("ok", dr.Id);


            drbo.Create(dr);

            var resCreate = dbo.Create(dish);
            var resGet    = dbo.Read(dish.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);
            }