private void AddButton_OnClick(object sender, RoutedEventArgs e) { try { var unitOfWork = new UnitOfWork(new Entities()); var female = unitOfWork.Females.GetFemaleByCode(_female.code); var weaning = new Weaning { weaned_pigs = int.Parse(NPigsTextBox.Text), date = DatePicker.Text }; female.status = "Destetada"; OnStatusModified(female); unitOfWork.Weaning.Add(weaning); unitOfWork.Complete(); OnWeaningAdded(weaning); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
public virtual void OnWeaningAdded(Weaning weaning) { try { var unitOfWork = new UnitOfWork(new Entities()); var birth = unitOfWork.Births.GetCurrentBirth(_female); birth.weaning = weaning.id; birth.status = "Destetado"; unitOfWork.Complete(); OnBirthModified(birth); WeaningAdded?.Invoke(this, weaning); } catch (Exception e) { MessageBox.Show(e.Message); } }