Exemplo n.º 1
0
        public void FindPurchaseOrderHeaderSummaryListModelTest()
        {
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser, true);

            // Create a random number of purchases
            List <PurchaseOrderHeaderModel> pohList = new List <PurchaseOrderHeaderModel>();
            int numPohs = RandomInt(5, 25);

            for (int i = 0; i < numPohs; i++)
            {
                pohList.Add(GetTestPurchaseOrderHeader(testCompany, testUser, 10));
            }

            // Check that they are found
            var result   = PurchasingService.FindPurchaseOrderHeaderSummaryListModel(testCompany, testUser, 0, 1, PageSize, "");
            int actual   = result.Items.Count;
            int expected = numPohs;

            Assert.IsTrue(actual == expected, $"Error: {actual} items were returned when {expected} were expected");

            // Now delete them
            foreach (var poh in pohList)
            {
                PurchasingService.DeletePurchaseOrderHeader(poh);
            }

            // Now check that they have disappeared
            result   = PurchasingService.FindPurchaseOrderHeadersListModel(testCompany.Id, 0, 1, PageSize, "", 0, 0, 0);
            actual   = result.Items.Count;
            expected = 0;
            Assert.IsTrue(actual == expected, $"Error: {actual} items were returned when {expected} were expected");
        }
Exemplo n.º 2
0
        public ActionResult GetPurchases(int index, int pageNo, int pageSize, string search,
                                         int poStatus, int warehouse, int brandCategory,
                                         string sortColumn, int sortOrder)
        {
            var model = createModel();

            return(Json(PurchasingService.FindPurchaseOrderHeadersListModel(model.CurrentCompany.Id,
                                                                            index,
                                                                            pageNo,
                                                                            pageSize,
                                                                            search,
                                                                            poStatus,
                                                                            warehouse,
                                                                            brandCategory,
                                                                            sortColumn,
                                                                            (SortOrder)sortOrder),
                        JsonRequestBehavior.AllowGet));
        }