public ActionResult GetPurchaseOrderDetailTemps(int index, int parentId, int pageNo, int pageSize, string search,
                                                 string sortColumn, int sortOrder)
 {
     return(Json(PurchasingService.FindPurchaseOrderDetailTempsListModel(CurrentCompany.Id, parentId, index, pageNo, pageSize, search,
                                                                         sortColumn, (SortOrder)sortOrder),
                 JsonRequestBehavior.AllowGet));
 }
Esempio n. 2
0
        public void DeletePurchaseOrderDetailTempTest()
        {
            // Get a test user
            var testUser     = GetTestUser();
            var testCompany  = GetTestCompany(testUser, true);
            var testPurchase = GetTestPurchaseOrderHeader(testCompany, testUser, 1);

            var pohtModel = PurchasingService.CopyPurchaseOrderToTemp(testCompany, testPurchase, testUser);
            var model     = PurchasingService.FindPurchaseOrderDetailTempsListModel(testCompany.Id, pohtModel.Id, 0, 1, PageSize, "");

            // Create a record
            var newItem = createPurchaseOrderDetailTemp(model);

            var error = PurchasingService.InsertOrUpdatePurchaseOrderDetailTemp(newItem, testUser, "");

            Assert.IsTrue(!error.IsError, error.Message);

            // Check that it was written
            var result = db.FindPurchaseOrderDetailTemp(newItem.Id);
            var test   = PurchasingService.MapToModel(result);

            AreEqual(model, test);

            // Now delete it
            PurchasingService.DeletePurchaseOrderDetailTemp(newItem.Id);

            // And check that is was deleted
            result = db.FindPurchaseOrderDetailTemp(newItem.Id);
            Assert.IsTrue(result == null, "Error: A non-NULL value was returned when a NULL value was expected - record delete failed");
        }
Esempio n. 3
0
        public void FindPurchaseOrderDetailTempModelTest()
        {
            var testUser     = GetTestUser();
            var testCompany  = GetTestCompany(testUser, true);
            var testPurchase = GetTestPurchaseOrderHeader(testCompany, testUser, 1);

            var pohtModel = PurchasingService.CopyPurchaseOrderToTemp(testCompany, testPurchase, testUser);
            var model     = PurchasingService.FindPurchaseOrderDetailTempsListModel(testCompany.Id, pohtModel.Id, 0, 1, PageSize, "");

            var newItem = createPurchaseOrderDetailTemp(model);
            var error   = PurchasingService.InsertOrUpdatePurchaseOrderDetailTemp(newItem, testUser, "");

            Assert.IsTrue(!error.IsError, $"Error: {error.Message}");

            var test = PurchasingService.FindPurchaseOrderDetailTempModel(newItem.Id, null, false);

            AreEqual(model, test);
        }
Esempio n. 4
0
        public void FindPurchaseOrderDetailTempsListModelTest()
        {
            var testUser     = GetTestUser();
            var testCompany  = GetTestCompany(testUser, true);
            var testPurchase = GetTestPurchaseOrderHeader(testCompany, testUser, 10);

            var pohtModel = PurchasingService.CopyPurchaseOrderToTemp(testCompany, testPurchase, testUser);

            var model  = PurchasingService.FindPurchaseOrderDetailTempsListModel(testCompany.Id, pohtModel.Id, 0, 1, PageSize, "");
            var dbData = db.FindPurchaseOrderDetailTemps(testCompany.Id, pohtModel.Id);

            int expected = dbData.Count(),
                actual   = model.Items.Count();

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

            // Check that all the items match
            foreach (var item in model.Items)
            {
                var dbItem = dbData.Where(m => m.Id == item.Id).FirstOrDefault();
                Assert.IsTrue(dbItem != null, "Error: Model item not found in db item list");
                var temp = PurchasingService.MapToModel(dbItem);
                AreEqual(item, temp);
            }

            // Add another item a make sure it is found
            var newItem = createPurchaseOrderDetailTemp(model);
            var error   = PurchasingService.InsertOrUpdatePurchaseOrderDetailTemp(newItem, testUser, "");

            Assert.IsTrue(!error.IsError, $"Error: {error.Message}");

            model = PurchasingService.FindPurchaseOrderDetailTempsListModel(testCompany.Id, pohtModel.Id, 0, 1, PageSize, "");
            var testItem = model.Items.Where(i => i.Id == newItem.Id).FirstOrDefault();

            Assert.IsTrue(testItem != null, "Error: A NULL value was returned when a non-NULL value was expected");

            // Delete it and make sure it disappears
            PurchasingService.DeletePurchaseOrderDetailTemp(newItem.Id);

            model    = PurchasingService.FindPurchaseOrderDetailTempsListModel(testCompany.Id, pohtModel.Id, 0, 1, PageSize, "");
            testItem = model.Items.Where(i => i.Id == newItem.Id).FirstOrDefault();
            Assert.IsTrue(testItem == null, "Error: A non-NULL value was returned when a NULL value was expected");
        }
Esempio n. 5
0
        public void LockPurchaseOrderDetailTempTest()
        {
            var testUser     = GetTestUser();
            var testCompany  = GetTestCompany(testUser, true);
            var testPurchase = GetTestPurchaseOrderHeader(testCompany, testUser, 1);

            var pohtModel = PurchasingService.CopyPurchaseOrderToTemp(testCompany, testPurchase, testUser);
            var model     = PurchasingService.FindPurchaseOrderDetailTempsListModel(testCompany.Id, pohtModel.Id, 0, 1, PageSize, "");

            // Create a record
            var newItem = createPurchaseOrderDetailTemp(model);

            var error = PurchasingService.InsertOrUpdatePurchaseOrderDetailTemp(newItem, testUser, "");

            Assert.IsTrue(!error.IsError, $"Error: {error.Message}");

            // Get the current Lock
            string lockGuid = PurchasingService.LockPurchaseOrderDetailTemp(newItem);

            Assert.IsTrue(!string.IsNullOrEmpty(lockGuid), "Error: Lock record was not found");

            // Simulate another user updating the record
            var otherUser = GetTestUser();

            error = PurchasingService.InsertOrUpdatePurchaseOrderDetailTemp(newItem, otherUser, lockGuid);
            Assert.IsTrue(!error.IsError, error.Message);

            // Now get the first user to update the record
            error = PurchasingService.InsertOrUpdatePurchaseOrderDetailTemp(newItem, testUser, lockGuid);
            Assert.IsTrue(error.IsError, "Error: The lock should have caused an error as it has changed");

            // Try to update with the new lock
            lockGuid = PurchasingService.LockPurchaseOrderDetailTemp(newItem);
            error    = PurchasingService.InsertOrUpdatePurchaseOrderDetailTemp(newItem, testUser, lockGuid);
            Assert.IsTrue(!error.IsError, $"Error: {error.Message}");
        }