I created a simple application, but when I click on the action button responsible for saving the data, the program stops working.
Here's a picture:
Save button action: -
private void button_Click(object sender, RoutedEventArgs e)
{
Chemical newChemical = new Chemical();
newChemical.ChemicalName = nameField.Text;
newChemical.ChemicalFormula = formulaField.Text;
newChemical.MW = Decimal.Parse(MWField.Text);
newChemical.VFId = Int32.Parse(VFIDField.Text);
ctrl.Create(newChemical);
}
Control Code (ctrl):
public class ChemicalCtrl
{
public ChemicalCtrl()
{ }
public void Create(Chemical ch)
{
//throw new NotImplementedException();
try
{
using (var repo = new Repository<Chemical>())
{
repo.Create(ch);
}
}
catch(CustomExceptionsCtrl err)
{
Console.WriteLine(err);
}
}
}
DETAIL: I have already tested the 'Create ()' method on a console application, it is working perfectly.