public void TestGetByUid()
        {
            ComboItemDto comboItemDto = this.GetComboItem01();

            ComboItemProxy proxy = new ComboItemProxy();

            proxy.Insert(comboItemDto);

            Assert.AreNotEqual(0, comboItemDto.Uid);

            ComboItemDto result = (ComboItemDto)proxy.GetByUid(comboItemDto.Uid);

            Assert.AreEqual(2, result.Items.Count);

            proxy.DeleteByUid(comboItemDto.Uid);

            try
            {
                proxy.GetByUid(comboItemDto.Uid);
            }
            catch (RestException ex)
            {
                StringAssert.Contains("Unable to find inventory item uid ", ex.Message);
            }
        }
        public void DeleteReferenced()
        {
            ComboItemProxy proxy     = new ComboItemProxy();
            ComboItemDto   comboItem = this.GetComboItem01();

            proxy.Insert(comboItem);

            // We need to insert stock first using a purchase
            CrudProxy  invoiceProxy = new InvoiceProxy();
            InvoiceDto dto          = new InvoiceDto(TransactionType.Purchase, InvoiceLayout.Item);

            dto.Date                = DateTime.Today.Date;
            dto.ContactUid          = this.MrSmith.Uid;
            dto.Summary             = "Using a combo item.";
            dto.Notes               = "From REST";
            dto.DueOrExpiryDate     = dto.Date.AddMonths(1);
            dto.Status              = InvoiceStatus.Invoice;
            dto.InvoiceNumber       = "I123";
            dto.PurchaseOrderNumber = "<Auto Number>";

            decimal unitsToBuild = 12.25M;

            // "purchase" all the items that are part of this combo item so we have valid stock
            ItemInvoiceItemDto item = new ItemInvoiceItemDto();

            item.Quantity         = 5;
            item.InventoryItemUid = comboItem.Uid;
            item.Description      = "Purchasing: " + comboItem.Description;
            item.TaxCode          = TaxCode.ExpInclGst;
            item.UnitPriceInclTax = 99.95M;
            dto.Items.Add(item);
            invoiceProxy.Insert(dto);

            try
            {
                proxy.DeleteByUid(comboItem.Uid);
                Assert.Fail("Expected exception was not thrown.");
            }
            catch (RestException ex)
            {
                Assert.AreEqual("The specified inventory item is referenced by some Transactions and/or Combo Items  and therefore cannot be deleted.", ex.Message);
            }
        }
        public void Delete()
        {
            ComboItemDto   comboItemDto = this.GetComboItem01();
            ComboItemProxy proxy        = new ComboItemProxy();

            proxy.Insert(comboItemDto);

            proxy.DeleteByUid(comboItemDto.Uid);

            try
            {
                ComboItemDto fromDB = (ComboItemDto)proxy.GetByUid(comboItemDto.Uid);
                Assert.Fail("The Combo Item was not deleted successfully.");
            }
            catch (RestException ex)
            {
                Assert.IsTrue(ex.Type == "RecordNotFoundException", "Expected exception RecordNotFoundException not thrown.");
            }
        }