private void ChangeKeyLogic() { if (!string.IsNullOrEmpty(SelectedAddress.AddressID)) {//check to see if key is part of the current companylist... Address query = AddressList.Where(company => company.AddressID == SelectedAddress.AddressID && company.AutoID != SelectedAddress.AutoID).FirstOrDefault(); if (query != null) {//revert it back SelectedAddress.AddressID = SelectedAddressMirror.AddressID; //change to the newly selected company... SelectedAddress = query; return; } //it is not part of the existing list try to fetch it from the db... AddressList = GetAddressByID(SelectedAddress.AddressID, XERP.Client.ClientSessionSingleton.Instance.CompanyID); if (AddressList.Count == 0)//it was not found do new record required logic... { NotifyNewRecordNeeded("Record " + SelectedAddress.AddressID + " Does Not Exist. Create A New Record?"); } else { SelectedAddress = AddressList.FirstOrDefault(); } } else { string errorMessage = "ID Is Required."; NotifyMessage(errorMessage); //revert back to the value it was before it was changed... if (SelectedAddress.AddressID != SelectedAddressMirror.AddressID) { SelectedAddress.AddressID = SelectedAddressMirror.AddressID; } } }
// Адрес в строку public string GetAddressToString(int id) { var adr = AddressList.FirstOrDefault(m => m.AddressID == id); string addr = adr.Country + ", " + adr.Locality + ", " + adr.Street + ", " + adr.House + "/ " + adr.Apartment; return(addr); }
private void OnSearchResult(object sender, NotificationEventArgs <BindingList <Address> > e) { if (e.Data != null && e.Data.Count > 0) { AddressList = e.Data; SelectedAddress = AddressList.FirstOrDefault(); Dirty = false; AllowCommit = false; } UnregisterToReceiveMessages <BindingList <Address> >(MessageTokens.AddressSearchToken.ToString(), OnSearchResult); }
public string GetAddress(Guid departmentId) { if (!AddressList.HasValue()) { return(null); } var address = AddressList.FirstOrDefault(i => i.HousingDepartmentId == departmentId)?.Address; return(address); }
public void ChangeAddress(Guid housingDepartmentId, string address) { var addressItem = AddressList.FirstOrDefault(x => x.HousingDepartmentId == housingDepartmentId); if (addressItem == null) { addressItem = new JobAddress { HousingDepartmentId = housingDepartmentId, Address = address }; AddressList.Add(addressItem); } else { addressItem.Address = address; } RaiseEvent(new JobAddressChanged { AddressList = AddressList }); }