void DelEmployeeView()
        {
            if (SelectedEmplViews != null)
            {
                IEnumerable <EmployeeView> emplViewsToDel = SelectedEmplViews.Cast <EmployeeView>();
                while (emplViewsToDel.Where(i => i.IsAdded).Count() > 0)
                {
                    EmployeeViews.Remove(emplViewsToDel.First(i => i.IsAdded));
                }

                foreach (var eV in emplViewsToDel)
                {
                    if (eV.IsAdded == false)
                    {
                        eV.IsDeleted = true;
                    }
                }
                if (EmployeeViews.FirstOrDefault(eV => eV.IsAdded || eV.IsDeleted) != null)
                {
                    IsEmployeeViewsChanged = true;
                }
                else
                {
                    IsEmployeeViewsChanged = false;
                }
            }
        }
        void DataLoading()
        {
            List <Employee> employees = new List <Employee>();

            try
            {
                DIConfig.ComposeContainer.ComposeParts(this);
                EmployeeLogic.Login    = Credentials.Login;
                EmployeeLogic.Password = Credentials.Password;
                employees = EmployeeLogic.GetEmployees();
            }
            catch (Exception ex)
            {
                MessageBoxVM = new MessageBoxModel()
                {
                    Message = ErrorMessage.MakingMessageForMessageBox(ex),
                    Caption = errCaption
                };
                Log.WriteLogAsync(ex);
            }

            Mapper.Map <List <EmployeeView> >(employees)
            .ForEach(e =>
            {
                e.PropertyChanged += (s, eArgs) =>
                                     OnEmployeeViewChnaged(e, eArgs.PropertyName);
                e.EmplProjViews.CollectionChanged += (s, eArgs) =>
                                                     OnEmplProjViewsCountChanged(e, eArgs.NewItems, eArgs.OldItems);
                e.LeadProjViews.CollectionChanged += (s, eArgs) =>
                                                     OnLeadProjViewsCountChanged(e, eArgs.NewItems, eArgs.OldItems);
                EmployeeViews.Add(e);
            });
            CurrentEmplView = EmployeeViews.FirstOrDefault();
        }
        void CancelChanges()
        {
            if (EmployeeViews.Where(e => e.IsAdded).Count() > 0 ||
                EmployeeViews.Where(e => e.IsChanged).Count() > 0 ||
                EmployeeViews.Where(e => e.IsDeleted).Count() > 0)
            {
                MessageBoxVM = new MessageBoxModel()
                {
                    Message = "Все внесённые изменения будут удалены. Продолжить?",
                    Caption = "сотрудники",
                    Buttons = MessageBoxButton.YesNo
                };
                if (MessageBoxVM.Result == MessageBoxResult.Yes)
                {
                    int numOfAdded = 0;
                    foreach (var eV in EmployeeViews)
                    {
                        if (eV.IsAdded)
                        {
                            numOfAdded++;
                        }
                        if (eV.IsChanged)
                        {
                            eV.Name = eV.Backup.Name;
                            if (eV.IsChanged)
                            {
                                eV.Surname = eV.Backup.Surname;
                            }
                            if (eV.IsChanged)
                            {
                                eV.MiddleName = eV.Backup.MiddleName;
                            }
                            if (eV.IsChanged)
                            {
                                eV.EMail = eV.Backup.EMail;
                            }
                        }
                        if (eV.IsDeleted)
                        {
                            eV.IsDeleted = false;
                        }
                    }
                    while (numOfAdded > 0)
                    {
                        EmployeeViews.Remove(EmployeeViews.First(eV => eV.IsAdded));
                        numOfAdded--;
                    }

                    if (EmployeeViews.FirstOrDefault(eV => eV.IsAdded || eV.IsDeleted) != null)
                    {
                        IsEmployeeViewsChanged = true;
                    }
                    else
                    {
                        IsEmployeeViewsChanged = false;
                    }
                }
            }
        }
 void AddEmployeeView()
 {
     EmployeeViews.Add(new EmployeeView());
     EmployeeViews.Last().IsAdded = true;
     if (EmployeeViews.FirstOrDefault(eV => eV.IsAdded) != null)
     {
         IsEmployeeViewsChanged = true;
     }
 }
        void DataLoading()
        {
            EmployeeLogic.Login    = Credentials.Login;
            EmployeeLogic.Password = Credentials.Password;

            IProgress <bool>            queryExecutionProgress   = new Progress <bool>(inProgress => LoadFromDbInProgress = inProgress);
            IProgress <EmployeeView>    GetEmployeeViewsProgress = new Progress <EmployeeView>(emplView => EmployeeViews.Add(emplView));
            IProgress <MessageBoxModel> messageReport            = new Progress <MessageBoxModel>(messageBoxVM => MessageBoxVM = messageBoxVM);

            Task.Run(() =>
            {
                List <Employee> employees = new List <Employee>();
                try
                {
                    queryExecutionProgress.Report(true);
                    employees = EmployeeLogic.GetEmployees();
                }
                catch (Exception ex)
                {
                    messageReport.Report(new MessageBoxModel()
                    {
                        Message = ErrorMessage.MakingMessageForMessageBox(ex),
                        Caption = errCaption
                    });
                    Log.WriteLogAsync(ex);
                }

                Mapper.Map <List <EmployeeView> >(employees)
                .ForEach(e =>
                {
                    e.PropertyChanged += (s, eArgs) =>
                                         OnEmployeeViewChnaged(e, eArgs.PropertyName);
                    e.EmplProjViews.CollectionChanged += (s, eArgs) =>
                                                         OnEmplProjViewsCountChanged(e, eArgs.NewItems, eArgs.OldItems);
                    e.LeadProjViews.CollectionChanged += (s, eArgs) =>
                                                         OnLeadProjViewsCountChanged(e, eArgs.NewItems, eArgs.OldItems);
                    GetEmployeeViewsProgress.Report(e);
                });
                queryExecutionProgress.Report(false);
            });
            CurrentEmplView = EmployeeViews.FirstOrDefault();
        }