public void TestDeletePersonAsync()
        {
            RestaurantSeeder.Seed();
            var bo        = new PersonBusinessObject();
            var resList   = bo.ListAsync().Result;
            var resDelete = bo.DeleteAsync(resList.Result.First().Id).Result;

            resList = bo.ListNonDeletedAsync().Result;
            Assert.IsTrue(resDelete.Success && resList.Success && resList.Result.Count == 0);
        }
        public void TestUpdatePersonAsync()
        {
            RestaurantSeeder.Seed();
            var bo      = new PersonBusinessObject();
            var resList = bo.ListAsync().Result;
            var item    = resList.Result.FirstOrDefault();

            item.FirstName = "another";
            var resUpdate = bo.UpdateAsync(item).Result;

            resList = bo.ListNonDeletedAsync().Result;
            Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().FirstName == "another");
        }
Beispiel #3
0
        public async Task <IActionResult> ListAsync()
        {
            var listResult = await _bo.ListNonDeletedAsync();

            if (!listResult.Success)
            {
                return(InternalServerError(listResult.Exception));
            }
            var list = listResult.Result;
            var lst  = new List <PersonViewModel>();

            foreach (var item in list)
            {
                var vm = PersonViewModel.Parse(item);
                lst.Add(vm);
            }
            return(Ok(lst));
        }
Beispiel #4
0
        public async Task <IActionResult> Index()
        {
            var listOperation = await _bo.ListNonDeletedAsync();

            if (!listOperation.Success)
            {
                return(View("Error", new ErrorViewModel()
                {
                    RequestId = listOperation.Exception.Message
                }));
            }
            var lst = new List <PersonViewModel>();

            foreach (var item in listOperation.Result)
            {
                lst.Add(PersonViewModel.Parse(item));
            }
            ViewData["Header"] = "Persons";
            return(View(lst));
        }