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 AddEmployeeView() { EmployeeViews.Add(new EmployeeView()); EmployeeViews.Last().IsAdded = true; if (EmployeeViews.FirstOrDefault(eV => eV.IsAdded) != null) { IsEmployeeViewsChanged = true; } }
void FilterViewFromDB() { if (LoadFromDb == true) { List <Employee> employees = new List <Employee>(); try { if (EmployeeViews.Where(eV => eV.IsAdded).Count() > 0 || EmployeeViews.Where(eV => eV.IsChanged).Count() > 0 || EmployeeViews.Where(eV => eV.IsDeleted).Count() > 0) { MessageBoxVM = new MessageBoxModel() { Message = "Все внесённые изменения будут удалены. Продолжить?", Caption = "сотрудники", Buttons = MessageBoxButton.YesNo }; if (MessageBoxVM.Result == MessageBoxResult.Yes) { while (EmployeeViews.Count > 0) { EmployeeViews.Remove(EmployeeViews.First()); } employees = LoadFilteredDataFromDb(FilterControlName); } } else { while (EmployeeViews.Count > 0) { EmployeeViews.Remove(EmployeeViews.First()); } employees = LoadFilteredDataFromDb(FilterControlName); } } 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); }); } }
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(); }