private async Task SaveExistCase(SRiUtilityAddress uaddress) { try { Exception err; SRiRequestGroup s_RequestGroup = AppData.PropertyModel.SelectedProperty.RequestGroups[0]; SRiRecordMeta s_Record = AppData.PropertyModel.SelectedRecord.Record; // s_Record.Record.Address = EdAddress.Text; s_Record.Record.UPRN = uaddress?.UPRN.ToString() ?? null; s_Record.Record.Latitude = uaddress?.Latitude ?? s_Record.Record.Latitude; s_Record.Record.Longitude = uaddress?.Longitude ?? s_Record.Record.Longitude; s_Record.Record.TradeName = TxtTradeName.Text; s_Record.Record.Received = RcvdDueDate.Date + RcvdDueTime.Time; s_Record.Record.RequestType = AppData.ConfigModel.AllRequestTypes( AppData.MainModel.CurrentUser.Organisations.Select(x => x.Organisation.Name).FirstOrDefault()) .FirstOrDefault(x => x.Description == PkrRequestType.Items[PkrRequestType.SelectedIndex]).Code; s_RequestGroup.Name = s_Record.RequestTypeDescription; s_RequestGroup.GroupType = s_Record.Record.RequestType; s_Record.Record.Inspections[0].InspectionType = AppData.ConfigModel.Inspections( AppData.MainModel.CurrentUser.Organisations.Select(x => x.Organisation.Name).FirstOrDefault()) .FirstOrDefault(x => x.Description == PkrInspectionType.Items[PkrInspectionType.SelectedIndex]).Code; s_Record.Record.Details = EdPropertyDetails.Text; // AppData.PropertyModel.Update(s_Record, s_Record); //AppData.PropertyModel.SelectedProperty.UpdateFields(); await SplitView.HubMaster.ReloadPropertyData(); } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
private async Task SaveNewCase() { try { List <SRiProperty> properties; SRiUtilityAddress selectedAddress = null; // SaveNewCaseModel(); // selectedAddress = VerifyUtilityAddress(NewCaseVm.NewCaseAddressValue); // var newRecordEntityKey = Guid.NewGuid().ToString(); AppData.PropertyModel.AddNewRecord(new SRiRecordMeta() { ID = newRecordEntityKey, Organisation = AppData.MainModel.CurrentUser.Organisations[0].Organisation.Name, Received = "2", Version = "", QueryState = "", EntityMeta = new SRiEntityMeta("entitykey", newRecordEntityKey), Record = new SRiRecord() { EntityKey = newRecordEntityKey, KeyVal = OnSiteSettings.NewTempKey, Address = NewCaseVm.NewCaseAddressValue?.Trim(), Details = NewCaseVm.NewCaseDetails?.Trim(), Latitude = selectedAddress?.Latitude ?? SelectedLatitude, Longitude = selectedAddress?.Longitude ?? SelectedLongitude, UPRN = selectedAddress?.UPRN.ToString(), Received = NewCaseVm.NewCaseReceivedDate + NewCaseVm.NewCaseReceivedTime, RequestType = NewCaseVm.NewCaseRequestTypeText, TradeName = NewCaseVm.NewCaseTradeName?.Trim(), Status = SyncStatus.New, Inspections = new List <SRiInspection>() { new SRiInspection() { KeyVal = Guid.NewGuid().ToString(), InspectionType = NewCaseVm.NewInspectionTypeText, RiskRecords = new List <SRiXRRec>(), } } }, }); // await SplitView.HubMaster.ReloadPropertyData(); SplitView.InspectionCount?.Update(); // } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } //AppData.PropertyModel.Update(properties, true); }
/// ----------------------------------------------------------------------------------------------- /// Name FormattedAddress /// /// <summary> Formats the address from the ordnance survey to remove the comma /// between house number and street name. /// </summary> /// <param name="address"> The ordnance survey address model.</param> /// /// <returns> Formatted address string. /// </returns> /// ----------------------------------------------------------------------------------------------- /// public static string FormattedAddress(this SRiUtilityAddress address) { int index; // index = address.Address.IndexOf(','); if (index != -1) { return(address.Address.Remove(index, 1)); } else { return(address.Address); } }
private SRiUtilityAddress VerifyUtilityAddress(string caseAddress) { try { SRiUtilityAddress selectedAddress = null; if (caseAddress == null || UtilityAddressesByCoord?.Addresses == null) { return(null); } if (UtilityAddressesByCoord != null) { foreach (var address in UtilityAddressesByCoord.Addresses) { if (caseAddress == address.FormattedAddress()) { selectedAddress = address; break; } } } else if (UtilityAddressesByAdd != null) { foreach (var address in UtilityAddressesByAdd.Addresses) { if (caseAddress == address.FormattedAddress()) { selectedAddress = address; break; } } } return(selectedAddress); } catch (Exception) { return(null); } }