Ejemplo n.º 1
0
        public ActionResult SearchByItems(VoucherSearchForGridViewModel voucher)
        {
            DataTable dt = _anfVoucherService.GetByParameters(companyId, financialYearId, voucher.VoucherTypeId, voucher.ProjectId, voucher.DateFrom, voucher.ToDate, true);

            List<VoucherSearchResultViewModel> list = dt.DataTableToList<VoucherSearchResultViewModel>();
            foreach (VoucherSearchResultViewModel item in list)
            {
                item.DateString = item.Date.ToShortDateString();
            }

            return Json(list, JsonRequestBehavior.AllowGet);
        }
        public void SearchByItems()
        {
            //GetByParameters(companyId, financialYearId, voucher.VoucherTypeId, voucher.ProjectId, voucher.DateFrom, voucher.ToDate, true);
            VoucherSearchForGridViewModel voucher = new VoucherSearchForGridViewModel();
            voucher.VoucherTypeId = 3;
            voucher.ProjectId = 13221;
            voucher.DateFrom = DateTime.Now;
            voucher.ToDate = DateTime.Now;

            JsonResult json = controller.SearchByItems(voucher) as JsonResult;
            dynamic jsonCollection = json.Data;
            Assert.IsNotNull(json);
            Assert.IsInstanceOf(typeof(List<VoucherSearchResultViewModel>), json.Data, "Wrong View Model");
            List<VoucherSearchResultViewModel> list = new List<VoucherSearchResultViewModel>();
            list = json.Data as List<VoucherSearchResultViewModel>;
            Assert.AreEqual(5, list.Count);
        }