コード例 #1
0
        public ActionResult Create([FromBody] CourseViewModel vm)
        {
            var rt  = vm.ToCourse();
            var res = _bo.Create(rt);

            return(res.Success ? Ok() : 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);
            }
コード例 #3
0
        public ActionResult Create([FromBody] CourseViewModel vm)
        {
            var c   = vm.ToCourse();
            var res = _bo.Create(c);

            return(StatusCode(res.Success ? (int)HttpStatusCode.OK : (int)HttpStatusCode.InternalServerError));
        }
コード例 #4
0
        public ActionResult Create([FromBody] CourseViewModel vm)
        {
            var c = new Course(vm.Name);

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

            return(new ObjectResult(code));
        }
コード例 #5
0
        public void TestCreateAndListCourse()
        {
            RestaurantSeeder.Seed();
            var bo        = new CourseBusinessObject();
            var dr        = new Course("Vegetarian");
            var resCreate = bo.Create(dr);
            var resGet    = bo.Read(dr.Id);

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
コード例 #6
0
        public void TestCreateCourse()
        {
            ContextSeeders.Seed();
            var mbo = new CourseBusinessObject();

            var course    = new Course("pizza");
            var resCreate = mbo.Create(course);
            var resGet    = mbo.Read(course.Id);

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
コード例 #7
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);
            }