예제 #1
0
        public async Task <Tuple <int, List <BillFullInfoDTO> > > LoadAsyncCount(
            int skip = -1,
            int take = -1,
            BillSearchViewModel model = null)
        {
            //var query = (from bill in DbContext.Bill
            //             join subProject in DbContext.SubProject on bill.SubProjectId equals subProject.Id

            //             );

            var query = Entities.ProjectTo <BillFullInfoDTO>();



            int Count = query.Count();

            query = query.OrderByDescending(x => x.Id);


            if (skip != -1)
            {
                query = query.Skip((skip - 1) * take);
            }

            if (take != -1)
            {
                query = query.Take(take);
            }

            return(new Tuple <int, List <BillFullInfoDTO> >(Count, await query.ToListAsync()));
        }
예제 #2
0
        private static BillSearchViewModel GetBillSearchViewModel()
        {
            BillSearchViewModel bsvm = new BillSearchViewModel(new SqliteDbBillReaderWriter(Constants.CONN_STRING), _navigator);

            bsvm.FilterByDateFrom = new DateTime(DateTime.Now.Year, 1, 1);
            bsvm.PopUpWinService  = new MessageBoxService();
            return(bsvm);
        }
예제 #3
0
        public void TestBillSearchWillSwitchToBillDetailOnAdd()
        {
            NavigatorViewModel nav = new NavigatorViewModel();

            nav.ViewNameToDisplay = Constants.BillSearchView;
            BillSearchViewModel bs = new BillSearchViewModel(new MockBillReaderWriter(), nav);

            bs.AddBill.Execute(null);
            Assert.AreEqual(nav.ViewNameToDisplay, Constants.BillDetailView);
        }
        public async Task <IActionResult> Index(BillSearchViewModel searchModel)
        {
            //ViewBag.Organizations = await _organizationRepository.GetAllMapAsync<OrganizationIdTitleDTO>();

            var model = await _billRepository.LoadAsyncCount(
                this.CurrentPage,
                this.PageSize,
                searchModel);

            this.TotalNumber    = model.Item1;
            ViewBag.SearchModel = searchModel;

            return(View(model.Item2));
        }
        public void TestFilterByFromDate()
        {
            BillSearchViewModel vm = new BillSearchViewModel(new MockBillReaderWriter(), null);

            Assert.AreEqual(vm.BillList.Count, 0);

            vm.RequestBills.Execute(null);
            Assert.AreEqual(vm.BillList.Count, 3);

            vm.FilterByDateFrom = new DateTime(2019, 1, 2);

            vm.RequestBills.Execute(null);
            Assert.AreEqual(vm.BillList.Count, 2);
            Assert.AreEqual(vm.BillList[0].Id, 2);
            Assert.AreEqual(vm.BillList[1].Id, 3);
        }
        public void TestBillSearchViewModelCanGetAllBills()
        {
            BillSearchViewModel vm = new BillSearchViewModel(new MockBillReaderWriter(), null);

            Assert.AreEqual(vm.BillList.Count, 0);

            vm.RequestBills.Execute(null);

            Assert.AreEqual(vm.BillList.Count, 3);
            Assert.AreEqual(vm.BillList[0].Id, 1);
            Assert.AreEqual(vm.BillList[0].Type, BillType.Food);
            Assert.AreEqual(vm.BillList[1].Id, 2);
            Assert.AreEqual(vm.BillList[1].Type, BillType.Utility);
            Assert.AreEqual(vm.BillList[2].Id, 3);
            Assert.AreEqual(vm.BillList[2].Type, BillType.MiscSpending);
        }
예제 #7
0
        public void TestBillDetailCanLoadCorrectWhenClickingOnBillOnBillSearch()
        {
            NavigatorViewModel nav = new NavigatorViewModel();

            nav.ViewNameToDisplay = Constants.BillSearchView;
            MockBillReaderWriter billReaderWriter = new MockBillReaderWriter();
            BillSearchViewModel  bs = new BillSearchViewModel(billReaderWriter, nav);

            var allBills = billReaderWriter.GetAllBills();

            bs.SelectedBill = allBills[1];
            bs.OnGridDataRowClicked.Execute(null);

            Assert.AreEqual(nav.ViewNameToDisplay, Constants.BillDetailView);
            Assert.AreEqual(nav.BillIdSelected, 2);
            Assert.IsTrue(bs.SelectedBill.SameData(new BillInfo()));
        }
        public void TestFilterByPaidStatus()
        {
            BillSearchViewModel vm = new BillSearchViewModel(new MockBillReaderWriter(), null);

            Assert.AreEqual(vm.BillList.Count, 0);

            vm.RequestBills.Execute(null);
            Assert.AreEqual(vm.BillList.Count, 3);

            vm.FilterByPaidStatus = BillSearchViewModel.PaidStatusFilter.Paid;
            vm.RequestBills.Execute(null);
            Assert.AreEqual(vm.BillList.Count, 1);
            Assert.AreEqual(vm.BillList[0].Id, 2);

            vm.FilterByPaidStatus = BillSearchViewModel.PaidStatusFilter.Unpaid;
            vm.RequestBills.Execute(null);
            Assert.AreEqual(vm.BillList.Count, 2);
            Assert.AreEqual(vm.BillList[0].Id, 1);
            Assert.AreEqual(vm.BillList[1].Id, 3);
        }
예제 #9
0
 public void Cleanup()
 {
     this._mockRepository      = null;
     this._billSearchViewModel = null;
     GC.Collect();
 }
예제 #10
0
 public void Init()
 {
     this._mockRepository      = new Mock <IRepository>();
     this._mockDialogService   = new Mock <IDialogService>();
     this._billSearchViewModel = new BillSearchViewModel(this._mockRepository.Object, this._mockDialogService.Object);
 }