private void Btn_Add_Submit_Click(object sender, RoutedEventArgs e) { int serviceCount = App.listOfServices.Count; if (btnName == "Add") { var newService = new Servicesinfo { ServiceId = "S" + ++serviceCount, ServiceType = Cbx_Serv_List.SelectedValue.ToString(), Price = Txt_Price.Text, Description = Txt_Description.Text, Location = Txt_Location.Text, PostedDate = Dp_Date.Text, PersonId = App.loginPersonInfo.Email }; foreach (var person in App.listOfPersons) { if (person.Email == App.loginPersonInfo.Email) { person.Offered_services.Add(newService.ServiceId); break; } } App.listOfServices.Add(newService); } else { App.listOfServices.Where(S => S.ServiceId == selelctedService.ServiceId) .Select(S => { S.ServiceType = Cbx_Serv_List.SelectedValue.ToString(); S.Price = Txt_Price.Text; S.Location = Txt_Location.Text; S.Description = Txt_Description.Text; return(S); }).ToList(); } Mystorage.WriteXML <ObservableCollection <Servicesinfo> >("Serviceinfo.xml", App.listOfServices); Mystorage.WriteXML <ObservableCollection <Personinfo_with_service_details> >("Personinfowithservicedetails.xml", App.listOfPersons); MessageBox.Show("Service Added Successfully...."); OfferService.UpdateServiceList(); this.Close(); }