Esempio n. 1
0
        private void SaveTrainer(object obj)
        {
            try
            {
                //if (EmployeeShortImage != null && EmployeeShortImage.UriSource != null)
                //SelectedTrainer.ShortPhoto = ImageUtil.ToBytes(EmployeeShortImage);

                var newObject = SelectedTrainer.Id;
                //SelectedTrainer.Type = (TrainerTypes)SelectedTrainerType.Value;

                var stat = _trainerService.InsertOrUpdate(SelectedTrainer);

                if (stat != string.Empty)
                {
                    MessageBox.Show("Can't save"
                                    + Environment.NewLine + stat, "Can't save", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }

                else if (newObject == 0)
                {
                    Trainers.Insert(0, SelectedTrainer);
                    SelectedTrainer.Number = _trainerService.GetTrainerNumber(SelectedTrainer.Id);
                    stat = _trainerService.InsertOrUpdate(SelectedTrainer);
                    if (stat != string.Empty)
                    {
                        MessageBox.Show("Can't save Number"
                                        + Environment.NewLine + stat, "Can't save", MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Can't save"
                                + Environment.NewLine + exception.Message, "Can't save", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }