예제 #1
0
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            if (workerListView.SelectedItem == null)
            {
                MessageBox.Show("errror");
                return;
            }
            Items it = (Items)workerListView.SelectedItem;

            workerRepositoty.Delete(it.wrk);
            workerRepositoty.DeleteFromCache(it.wrk.ID);

            IEnumerable <Worker> workers;

            workers = workerRepositoty.GetListFromCache();
            foreach (Worker wr in workers)
            {
                DateTime d2 = contractRepositoty.Get(p => p.WorkerId == wr.ID).Last().EndDate;
                TimeSpan d3 = d2 - DateTime.Now;
                workerListView.Items.Add(new Items
                {
                    wrk  = wr,
                    dep  = departamentRepositoty.GetByIdFromCahce(wr.DepartamentID),
                    date = d3
                });
            }
            workerListView.Items.Refresh();
        }