Ejemplo n.º 1
0
        private void EditCompanyAndPost(object parameter)
        {
            int prevIndex = SelectedIndexCurrentCompanyAndPost;
            var currentWorkerCompanyAndPostViewModel = new CurrentCompanyAndPostViewModel(SelectedCurrentCompanyAndPost, SelectedDirectoryWorkerStartDate, DateTime.Now);
            var currentWorkerCompanyAndPostView      = new CurrentCompanyAndPostView();

            currentWorkerCompanyAndPostView.DataContext = currentWorkerCompanyAndPostViewModel;
            currentWorkerCompanyAndPostView.ShowDialog();

            var currentCompanyAndPost = currentWorkerCompanyAndPostViewModel.CurrentCompanyAndPost;

            if (currentCompanyAndPost != null)
            {
                var postSalary = BC.GetDirectoryPostSalaryByDate(currentCompanyAndPost.DirectoryPost.Id, new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1));

                currentCompanyAndPost.Salary     = IsAdminSalary ? postSalary.AdminWorkerSalary.Value : postSalary.UserWorkerSalary;
                currentCompanyAndPost.HalfSalary = postSalary.UserWorkerHalfSalary ?? 0;

                if (CurrentCompaniesAndPosts.Any())
                {
                    var prevPost = CurrentCompaniesAndPosts[prevIndex != 0 ? prevIndex - 1 : 0];
                    prevPost.PostFireDate = currentCompanyAndPost.PostChangeDate.AddDays(-1);

                    if (prevIndex != (CurrentCompaniesAndPosts.Count - 1))
                    {
                        currentCompanyAndPost.PostFireDate = CurrentCompaniesAndPosts[prevIndex + 1].PostChangeDate.AddDays(-1);
                    }
                }

                CurrentCompaniesAndPosts.Remove(SelectedCurrentCompanyAndPost);
                CurrentCompaniesAndPosts.Insert(prevIndex, currentCompanyAndPost);
            }
        }
Ejemplo n.º 2
0
        private void RemoveCompanyAndPost(object parameter)
        {
            int index    = CurrentCompaniesAndPosts.IndexOf(SelectedCurrentCompanyAndPost);
            var fireDate = index < CurrentCompaniesAndPosts.Count - 1 ? CurrentCompaniesAndPosts[index + 1].PostChangeDate.AddDays(-1) : default(DateTime?);

            CurrentCompaniesAndPosts.Remove(SelectedCurrentCompanyAndPost);

            CurrentCompaniesAndPosts[index - 1].PostFireDate = fireDate;
        }