示例#1
0
        public ActionResult <MealViewModel> Get(Guid id)
        {
            var res = _bo.Read(id);

            if (res.Success)
            {
                if (res.Result == null)
                {
                    return(NotFound());
                }
                var mvm = MealViewModel.Parse(res.Result);
                return(mvm);
            }
            else
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
        }
示例#2
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);
        }
        public ActionResult <MealViewModel> Get(Guid id)
        {
            var res = _bo.Read(id);

            if (res.Success)
            {
                if (res.Result == null)
                {
                    return(NotFound());
                }

                var vm = MealViewModel.Parse(res.Result);
                return(vm);
            }
            else
            {
                return(InternalServerError());
            }
        }
示例#4
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);
        }
示例#5
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);
        }
示例#6
0
        public ActionResult <MealViewModel> Get(Guid id)
        {
            var res = _bo.Read(id);

            if (res.Success)
            {
                var mvm = new MealViewModel();
                if (res.Result == null)
                {
                    return(NotFound());
                }
                mvm.Id       = res.Result.Id;
                mvm.Name     = res.Result.Name;
                mvm.Starting = res.Result.StartingHours;
                mvm.Ending   = res.Result.EndingHours;
                return(mvm);
            }
            else
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
        }