public DataTable GetBranches() { DataTable items = new DataTable(); Type type = new Branch().GetType(); PropertyInfo[] properties = type.GetProperties(); foreach (PropertyInfo property in properties) { items.Columns.Add(property.Name, property.PropertyType); } List <Branch> locals = LocationsDataProvider.GetBranches(); foreach (Branch item in locals) { DataRow itemRow = items.NewRow(); for (int i = 0; i < properties.Length; i++) { itemRow[item.GetType().GetProperties()[i].Name] = item.GetType().GetProperties()[i].GetValue(item, null); } items.Rows.Add(itemRow); } if (items.Rows.Count > 0) { return(items); } return(null); }
public bool SubmitChanges(BranchDTO branchDTO) { if (branchDTO != null) { if (branchDTO.ID != Guid.Empty) { Branch item = new Branch(); item.ID = branchDTO.ID; item.LocationName = branchDTO.LocationName; item.Address = branchDTO.Address; item.PhoneNumber = branchDTO.PhoneNumber; item.ZipCode = branchDTO.ZipCode; return(LocationsDataProvider.SubmitChanges(item)); } else { Branch item = new Branch(); item.LocationName = branchDTO.LocationName; item.Address = branchDTO.Address; item.PhoneNumber = branchDTO.PhoneNumber; item.ZipCode = branchDTO.ZipCode; return(LocationsDataProvider.SubmitChanges(item)); } } return(false); }