Esempio n. 1
0
        private void processData(IEnumerable <Specification> specifications, DataOP op, ProjectBrief project)
        {
            if (specifications == null)
            {
                return;
            }



            foreach (var specification in specifications)
            {
                specification.ProjectBriefId = project.Id;
                if (DataOP.AddNew == op)
                {
                    _specificationRepository.Add(specification);
                }
                else if (DataOP.EDIT == op)
                {
                    specification.Item = null;
                    _specificationRepository.Update(specification);
                }
                else if (DataOP.DEL == op)
                {
                    var requestItem = _specificationRepository.GetById(specification.Id);
                    _specificationRepository.Delete(requestItem);
                }
            }
        }
        protected override async void Delete(object sender, RoutedEventArgs e)
        {
            try
            {
                SpecificationOverviewItem ToBeDeleted = ((FrameworkElement)sender).DataContext as SpecificationOverviewItem;

                string messageboxTitle   = String.Format(LangResource.MBTitleDeleteObj, ToBeDeleted.SpecName);
                string messageboxContent = String.Format(LangResource.MBContentDeleteObj, LangResource.TheSpec.ToLower(), ToBeDeleted.SpecName);

                MessageBoxManager.Yes = LangResource.Yes;
                MessageBoxManager.No  = LangResource.No;
                MessageBoxManager.Register();

                if (MessageBox.Show(messageboxContent,
                                    messageboxTitle,
                                    MessageBoxButton.YesNo,
                                    MessageBoxImage.Warning)
                    == MessageBoxResult.Yes)
                {
                    MessageBoxManager.Unregister();

                    _specRepo.Delete(ToBeDeleted.ID);
                    SpecList.Remove(ToBeDeleted);

                    await _specRepo.SaveChangesAsync();

                    BindData();
                }
                else
                {
                    MessageBoxManager.Unregister();
                }
            }
            catch (Exception)
            { MessageBoxManager.Unregister();
              MessageBox.Show(LangResource.ErrUpdateOverviewFailed); }
        }
 public int SpeciDelete(string ids)
 {
     return(_specificationRepository.Delete(ids));
 }