Exemplo n.º 1
0
        public void TestDeleteStaffTitleAsync()
        {
            RestaurantSeeder.Seed();
            var bo        = new StaffTitleBusinessObject();
            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);
        }
Exemplo n.º 2
0
        public void TestUpdateStaffTitleAsync()
        {
            RestaurantSeeder.Seed();
            var bo      = new StaffTitleBusinessObject();
            var resList = bo.ListAsync().Result;
            var item    = resList.Result.FirstOrDefault();
            var now     = DateTime.Now;

            item.BeginDate = now;
            var resUpdate = bo.UpdateAsync(item).Result;

            resList = bo.ListNonDeletedAsync().Result;
            Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().BeginDate == now);
        }
Exemplo n.º 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 <StaffTitleViewModel>();

            foreach (var item in list)
            {
                var vm = StaffTitleViewModel.Parse(item);
                lst.Add(vm);
            }
            return(Ok(lst));
        }
Exemplo n.º 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 <StaffTitleViewModel>();

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