/// ------------------------------------------------------------------------------------------------ /// <summary> /// Load the Record details /// </summary> private void OnLoad() { try { int visitcount = -1; //To Load the Record Summary Details _recordSummary = new CreateRecordList(); if (_recordSummary.Details.Count > 0) { var recordSummaryStackLayout = new RecordSummaryStackLayout(_recordSummary); S_RecordSummary.Children.Add(recordSummaryStackLayout); } //To load the Visits Details _lstVisitsList = new List <CreateVisitsList>(); if (AppData.PropertyModel.SelectedRecord.Record.Record.Inspections.Count > 0) { visitcount = AppData.PropertyModel.SelectedRecord.Record.Record.Inspections[0].Visits.Count; for (int j = 0; j < visitcount; j++) { var data = AppData.PropertyModel.SelectedRecord.Record.Record.Inspections[0].Visits[j]; _visitsData = new CreateVisitsList() { VisitTypeDescription = data.VisitTypeDescription, ScheduleDate = data.Visit.DateScheduled.ToString("dd MMM yyyy", "Scheduled for ", "Not scheduled"), CompletedDate = data.Visit.DateVisit.ToString("dd MMM yyyy", "Completed on ", "Outstanding"), VisitListIndex = j }; _lstVisitsList.Add(_visitsData); } } if (_lstVisitsList.Count > 0) { var recordSummaryStackLayout = new VisitsView(_lstVisitsList); S_RecordSummary.Children.Add(recordSummaryStackLayout); } else { var recordSummaryStackLayout = new VisitsView(_lstVisitsList); S_RecordSummary.Children.Add(recordSummaryStackLayout); //if visit has no value need to show add visit } //To Load the Customer Details _customerLists = new CreateCustomerList(); if (_customerLists.Details.Count > 0 || (AppData.PropertyModel.SelectedProperty.Status == SyncStatus.New)) { var recordSummaryStackLayout = new RecordSummaryStackLayout(_customerLists); S_RecordSummary.Children.Add(recordSummaryStackLayout); } } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
private void SaveDetails() { try { SRiCustomer customer = new SRiCustomer(); if (ContactsDetails.Count == 0) { customer.Name = Lbl_Name.Text; customer.RecordKeyVal = ""; customer.KeyVal = ""; customer.Address = EdAddress.Text; Contact = new List <SRiContact>() { new SRiContact() { ContactType = "PHONEH", ContactDescription = "Phone", ContactAddress = Lbl_Phone.Text, SRRecKeyVal = "", CustomerKeyVal = "", KeyVal = "" }, new SRiContact() { ContactType = "EMAIL", ContactDescription = "Email", ContactAddress = Lbl_Email.Text, SRRecKeyVal = "", CustomerKeyVal = "", KeyVal = "" }, new SRiContact() { ContactType = "MOBILE", ContactDescription = "Mobile", ContactAddress = Lbl_Moblie.Text, SRRecKeyVal = "", CustomerKeyVal = "", KeyVal = "" } }; customer.CustomerType = ContactTypes.Where(x => x.Description == Pkr_CustomerType.Items[Pkr_CustomerType.SelectedIndex]).Select(x => x.Code).FirstOrDefault(); customer.Contacts = Contact; AppData.PropertyModel.SelectedRecord.Record.Record.Customers.Add(customer); } else { if (AppData.PropertyModel.SelectedRecord.Record.Record.Customers.Count > 0) { foreach (var item in AppData.PropertyModel.SelectedRecord.Record.Record.Customers) { item.Name = Lbl_Name.Text; item.Address = EdAddress.Text; item.CustomerType = ContactTypes.Where( x => x.Description == Pkr_CustomerType.Items[Pkr_CustomerType.SelectedIndex]) .Select(x => x.Code) .FirstOrDefault(); foreach (var contcat in item.Contacts) { if (contcat.ContactType == "PHONEH") { contcat.ContactAddress = Lbl_Phone.Text; } if (contcat.ContactType == "EMAIL") { contcat.ContactAddress = Lbl_Email.Text; } if (contcat.ContactType == "MOBILE") { contcat.ContactAddress = Lbl_Moblie.Text; } } } } } AppData.PropertyModel.SelectedRecord.CreateMappings(); Exception error; AppData.PropertyModel.SaveCustomer(out error); _customerLists = new CreateCustomerList(); ContactsDetails = _customerLists.Details; // update UI in Listview SplitView.CenterPopupContent.DismisPopup(); UpdateContact?.Invoke(ContactsDetails); } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }