public async Task <IActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(RecordNotFound());
            }
            var getOperation = await _bo.ReadAsync((Guid)id);

            if (!getOperation.Success)
            {
                return(OperationErrorBackToIndex(getOperation.Exception));
            }
            if (getOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var vm = MealViewModel.Parse(getOperation.Result);

            ViewData["Title"] = "Meal";

            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "New", Controller = "Meals", Icon = "fa-search", Text = "Detail"
            });

            ViewData["BreadCrumbs"] = crumbs;
            return(View(vm));
        }
        public async Task <IActionResult> GetAsync(Guid id)
        {
            var getResult = await _bo.ReadAsync(id);

            if (!getResult.Success)
            {
                return(InternalServerError(getResult.Exception));
            }
            var item = getResult.Result;

            if (item == null)
            {
                return(NotFound());
            }
            var vm = MealViewModel.Parse(item);

            return(Ok(vm));
        }
Beispiel #3
0
        public void TestCreateAndListMealAsync()
        {
            RestaurantSeeder.Seed();
            var bo        = new MealBusinessObject();
            var dr        = new Meal("Vegetarian", "19", "20");
            var resCreate = bo.CreateAsync(dr).Result;
            var resGet    = bo.ReadAsync(dr.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
        public void TestCreateMealAsync()
        {
            ContextSeeders.Seed();
            var mbo = new MealBusinessObject();

            var meal      = new Meal("pizza", "7pm", "11pm");
            var resCreate = mbo.CreateAsync(meal).Result;
            var resGet    = mbo.ReadAsync(meal.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
Beispiel #5
0
        public void TestCreateAndReadMealAsync()
        {
            RestaurantSeeder.SeedCountries();
            var bo = new MealBusinessObject();

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

            var resCreate = bo.CreateAsync(meal).Result;
            var resGet    = bo.ReadAsync(meal.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
        public async Task <IActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var getOperation = await _bo.ReadAsync((Guid)id);

            if (!getOperation.Success)
            {
                return(View("Error", new ErrorViewModel()
                {
                    RequestId = getOperation.Exception.Message
                }));
            }
            if (getOperation.Result == null)
            {
                return(NotFound());
            }
            var vm = MealViewModel.Parse(getOperation.Result);

            return(View(vm));
        }
        private async Task <MealViewModel> GetMealViewModel(Guid id)
        {
            var getOperation = await _mbo.ReadAsync(id);

            return(MealViewModel.Parse(getOperation.Result));
        }