Esempio n. 1
0
        public void TestCreateAndReadCategoryAsync()
        {
            ContextSeeder.Seed();
            var bo        = new CategoryBusinessObject();
            var reg       = new Category("Alcoholic Beverages");
            var resCreate = bo.CreateAsync(reg).Result;
            var resGet    = bo.ReadAsync(reg.Id).Result;

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

            if (!getOperation.Success)
            {
                return(View("Error", getOperation.Exception.Message));
            }
            if (getOperation.Result == null)
            {
                return(RecordNotFound());
            }

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

            Draw("Details", "fa-search");
            return(View(vm));
        }
        private async Task <CategoryViewModel> GetCategoryViewModel(Guid id)
        {
            var getOperation = await _cbo.ReadAsync(id);

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