Esempio n. 1
0
        public void UpdateItemListing_InvalidItemListing()
        {
            setup();
            itemListingToTest.ItemListID = 99;

            int actual = ItemListingAccessor.UpdateItemListing(itemListingToEdit, itemListingToTest);

            if (actual == 0)
            {
                throw new ApplicationException("Concurrency Error");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Matt Lapka
        /// Created: 2015/02/14
        /// Updates an ItemListing object by sending the object in its original form and the object with the updated information
        /// </summary>
        /// <param name="newItemList">The ItemListing object containing the new data</param>
        /// <param name="oldItemList">The ItemListing object containing the original data</param>
        /// <returns>An int reflecting the number of rows affected-- should be 1</returns>
        public listResult EditItemListing(ItemListing newItemLists, ItemListing oldItemLists)
        {
            if (newItemLists.CurrentNumGuests > 0)
            {
                if (newItemLists.StartDate != oldItemLists.StartDate || newItemLists.EndDate != oldItemLists.EndDate)
                {
                    return(listResult.NoDateChange);
                }

                if (newItemLists.MaxNumGuests < newItemLists.CurrentNumGuests)
                {
                    return(listResult.MaxSmallerThanCurrent);
                }
                if (newItemLists.Price != oldItemLists.Price)
                {
                    return(listResult.NoPriceChange);
                }
            }

            if (newItemLists.StartDate > newItemLists.EndDate)
            {
                return(listResult.StartEndDateError);
            }
            if (newItemLists.StartDate < DateTime.Now)
            {
                return(listResult.DateInPast);
            }

            try
            {
                if (ItemListingAccessor.UpdateItemListing(newItemLists, oldItemLists) == 1)
                {
                    DataCache._currentItemListingList = ItemListingAccessor.GetItemListingList();
                    return(listResult.Success);
                }
                return(listResult.NotChanged);
            }
            catch (Exception)
            {
                return(listResult.DatabaseError);
            }
        }
Esempio n. 3
0
        public void UpdateItemListing_ValidItemListing()
        {
            int expected = 1;

            setup();

            SupplierAccessor.AddSupplier(testSupp, "Test", "Password#1");
            modSupp = getSupplierListCompName(suppList);
            itemListingToEdit.SupplierID = modSupp.SupplierID;
            ItemListingAccessor.AddItemListing(itemListingToTest);
            itemListingToTest            = getItemListingTestObject(itemList);
            itemListingToEdit.SupplierID = modSupp.SupplierID;

            int actual = ItemListingAccessor.UpdateItemListing(itemListingToEdit, itemListingToTest);

            ItemListingAccessor.DeleteItemListingTestItem(itemListingToEdit);
            testSupp.SupplierID = modSupp.SupplierID;
            testLog             = sLA.RetrieveSupplierLogin("Password#1", "Test");
            SupplierLoginAccessor.DeleteTestSupplierLogin(testLog);
            TestCleanupAccessor.DeleteTestSupplier(testSupp);

            Assert.AreEqual(expected, actual);
        }