Пример #1
0
        public void InsertWarehouseInDatabase()
        {
            using (TransactionScope scope = new TransactionScope()) //auto roll back
            {
                int       brojac    = 0;
                Warehouse warehouse = new Warehouse();

                warehouse.Name       = "Random name";
                warehouse.LocationId = 1024;

                warehouseRepositoryBus.InsertWarehouse(warehouse);

                foreach (Warehouse categ in warehouseRepositoryBus.GetAllWarehouses())
                {
                    if (categ.Name == warehouse.Name && categ.LocationId == warehouse.LocationId)
                    {
                        brojac++;
                    }
                }
                Assert.AreEqual(1, brojac);
            }
        }
Пример #2
0
 private void buttonInsert_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBoxName.Text))
     {
         MessageBox.Show("You have to fill every field in order to continue.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         try
         {
             Warehouse warehouse = new Warehouse();
             warehouse.Name       = textBoxName.Text;
             warehouse.LocationId = locationRepositoryBus.GetLocationIdByName(comboBoxLocation.SelectedItem.ToString());
             warehouseRepositoryBus.InsertWarehouse(warehouse);
             AutoClosingMessageBox.Show("You have successfully added your Warehouse!", "Congratulations!", 1700);
             this.Close();
         }
         catch (Exception)
         {
             MessageBox.Show("You have to fill every field in order to continue.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }