private void BtAdd_Click(object sender, RoutedEventArgs e) { if (CheckAll()) { checkFields(); _competition.Rules = bytes; _competition.Status = "OPEN"; if (PreinscriptionIsChecked()) { _competition.Preinscription = true; _competition.DaysPreinscription = int.Parse(PrecioInscripcion.Text); } else { _competition.Preinscription = false; } checkAges(); foreach (AbsoluteCategory c in Categories.Items ) //modificar las categorias que te devuelve el dialogo no el listbox { _serviceCategories.AddCategory(c.CategoryF); _serviceCategories.AddCategory(c.CategoryM); } //añadir absoluta categoria vincular _serviceComp.AddCompetition(_competition); _competition.ID = _serviceComp.GetIdCompetition(_competition); _serviceEnroll = new EnrollService(_competition); foreach (AbsoluteCategory c in Categories.Items) { var idm = _serviceCategories.GetCategory(c.CategoryM); var idf = _serviceCategories.GetCategory(c.CategoryF); var nueva = new AbsoluteCategory { Name = c.Name, CategoryF = idf, CategoryM = idm }; _serviceCategories.AddAbsoluteCategory(nueva); long id = _serviceComp.GetIdAbsolute(nueva); _serviceEnroll.EnrollAbsoluteCompetition(_competition.ID, id); } //vincular refunds y competicion foreach (var c in refundsList) { _serviceEnroll.EnrollRefundsCompetition(_competition.ID, c.date_refund, c.refund / 100); } //METER PLAZOS en inscription dates foreach (InscriptionDatesDto p in Plazos_list.Items) { _serviceComp.AddInscriptionDate(p, _competition); } MessageBox.Show("Competicion agregada correctamente."); clearAll(); } else { MessageBox.Show("Por favor, revise que todos los campos se han introducido correctamente"); } }