private void LoadNxNComboFor_EmployeeTerritories(EmployeesDataContext dataContext, out string error) { List <ModelNotifiedForTerritories> allTerritories = GetAllTerritories(out error); if (dataContext == null) { return; } var item = dataContext.modelNotifiedForEmployeesMain; List <ModelNotifiedForEmployeeTerritories> listEmployeeTerritories = GetAllEmployeeTerritories(item.EmployeeID, out error); List <ModelNotifiedForTerritories> comboItens = new List <ModelNotifiedForTerritories>(); foreach (ModelNotifiedForTerritories item2 in allTerritories) { ModelNotifiedForEmployeeTerritories aux = listEmployeeTerritories.Where(x => x.TerritoryID == item2.TerritoryID).FirstOrDefault(); bool existsInDB = (aux != null); ModelNotifiedForTerritories newComboItem = new ModelNotifiedForTerritories(); Cloner.CopyAllTo(typeof(ModelNotifiedForTerritories), item2, typeof(ModelNotifiedForTerritories), newComboItem); if (existsInDB) { newComboItem.Check_Status = true; } else { newComboItem.Check_Status = false; } comboItens.Add(newComboItem); } item.LookDownComboDataTerritories = comboItens.OrderBy(x => x.TerritoryDescription).ToList(); }
/// <summary> /// Empty data context is used when the from is loaded without ID (the from is in "insert mode") /// </summary> public EmployeesDataContext GetEmptyDataContext(out string error) { EmployeesDataContext dataContext = new EmployeesDataContext(); error = null; dataContext.modelNotifiedForEmployeesMain = new ModelNotifiedForEmployees();; dataContext.modelNotifiedForEmployees = GetAll_Employees(out error); return(dataContext); }
public EmployeesDataContext GetDataContext(int EmployeeID, out string error) { EmployeesDataContext dataContext = new EmployeesDataContext(); error = null; dataContext.modelNotifiedForEmployeesMain = GetEmployeesByID(EmployeeID, out error); dataContext.modelNotifiedForEmployees = GetAll_Employees(out error); dataContext.PopulateComboBoxesItemSource(); this.LoadNxNComboFor_EmployeeTerritories(dataContext, out error); return(dataContext); }