private async void church_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { if (Connectivity.NetworkAccess == NetworkAccess.Internet) { var tenantId = (e.CurrentSelection.FirstOrDefault() as Churches)?.tenantId; var name = (e.CurrentSelection.FirstOrDefault() as Churches)?.churchName; Preferences.Set("tenantId", tenantId); Preferences.Set("name", name); // await ApiServices.GetAllChurchFeeds(tenantId, Preferences.Get("userId", string.Empty)); var res = await ApiServices.GetChurchProfile(tenantId); if (res) { MessagingCenter.Send <SelectChurchPage>(this, "load"); var result = Preferences.Get("churchprofile", string.Empty); if (result != string.Empty) { //Profile = new ChurchProfile(JsonConvert.DeserializeObject<ChurchProfile>(result)); Profile = JsonConvert.DeserializeObject <ChurchProfile>(result); var colo = Profile.churchAppBackgroundColor != string.Empty ? Profile.churchAppBackgroundColor : "#fb2056"; Preferences.Set("appThemeColor", colo); if (string.IsNullOrEmpty(colo)) { Application.Current.Resources["PrimaryColor"] = Color.Green; } else { Application.Current.Resources["PrimaryColor"] = colo; } } else { //Application.Current.Resources["PrimaryColor"] = Color.FromHex("#000"); App.Current.MainPage = new SettingUpPage(); } } //if (string.IsNullOrEmpty(Preferences.Get("appThemeColor", string.Empty))) //{ // Application.Current.Resources["PrimaryColor"] = Color.Green; //} //else //{ // Application.Current.Resources["PrimaryColor"] = Color.FromHex("#" + Preferences.Get("appThemeColor", string.Empty)); //} App.Current.MainPage = new SettingUpPage(); } else { MessageDialog.Show("Error!", "Please Check Your Internet, and try again", "Cancel"); } } catch (Exception ex) { } }
private async void Button_Clicked(object sender, EventArgs e) { try { btn.IsVisible = false; loading.IsVisible = true; var res = await ApiServices.GetChurchProfile(App.AppKey); if (res) { var result = Preferences.Get("churchprofile", string.Empty); if (result != string.Empty) { Profile = JsonConvert.DeserializeObject <ChurchProfile>(result); } } loading.IsVisible = false; } catch { loading.IsVisible = false; btn.IsVisible = true; } App.Current.MainPage = new MainShellPage(); }
//[ValidateAntiForgeryToken] public async Task <ActionResult> SaveProfile(ChurchProfile churchProfile) { try { var json = await _apiProvider.PutItemAsync <ChurchProfile>($"{_uri}/{ churchProfile.Id}", churchProfile); var m = _apiProvider.DeserializeJson <ChurchProfile>(json); if (m != null) { // reload page, so that any new id's can be loaded. return(RedirectToAction("Edit", new { id = churchProfile.Id })); } else { return(Content("Error saving profile")); } } catch (Exception ex) { return(Content("Error saving profile: " + ex.Message)); } // var mpjson = await _apiProvider.PutItemAsync(_uri, $"id={id}"); //var cp = _apiProvider.DeserializeJson<ChurchProfile>(mpjson); return(new ContentResult() { Content = "Saved" }); // this prevents navigation to another page. }
public SelectChurchPage() { InitializeComponent(); GetListOfChurches(); Profile = new ChurchProfile(); }
public ChurchContactViewModel() { Profile = new ChurchProfile(); About = new ObservableCollection <About>(); Pastors = new ObservableCollection <Pastor>(); Banks = new ObservableCollection <Bank>(); GetProfile(); }
public ActionResult GetView(string viewName, int churchId) { ModuleBase viewModel = null; var viewPath = "/Views/Church/"; switch (viewName.ToLower()) { case "attributes": { viewModel = new ChurchAttributes(churchId); viewPath += "_ChurchAttributes.cshtml"; break; } case "communication": { viewModel = new ChurchCommunication(churchId); viewPath += "_ChurchCommunication.cshtml"; break; } case "notes": { viewModel = new ChurchNotes(churchId); viewPath += "_ChurchNotes.cshtml"; break; } case "history": { viewModel = new ChurchHistory(churchId); viewPath += "_ChurchHistory.cshtml"; break; } case "teams": { viewModel = new ChurchTeams(churchId); viewPath += "_ChurchTeams.cshtml"; break; } default: { viewModel = new ChurchProfile(); viewPath += "_ChurchProfile.cshtml"; break; } } //viewModel.Load(); return(PartialView(viewPath, viewModel)); }
public IHttpActionResult Put(int id, ChurchProfile church) { try { if (church == null) { return(BadRequest("church required")); } if (id != church.Id) { return(BadRequest("id and church.id must match")); } var result = _repository.SaveProfile(church); if (result.Status == RepositoryActionStatus.Updated) { return(Ok(church)); } else if (result.Status == RepositoryActionStatus.NotFound) { return(NotFound()); } else { return(BadRequest()); } } catch (Exception ex) { ErrorHelper.ProcessError(_logger, ex, nameof(Delete)); return(InternalServerError()); } }
public SettingUpPage() { InitializeComponent(); MessagingCenter.Send <SettingUpPage>(this, "loadFeed"); Profile = new ChurchProfile(); }
public AboutDetailViewModel() { Profile = new ChurchProfile(); Abouts = new ObservableCollection <About>(); Poulate(); }
public RepositoryActionResult <ChurchProfile> SaveProfile(ChurchProfile profile) { var paramz = new List <SqlParameter>(); paramz.Add(new SqlParameter("churchId", profile.Id)); paramz.Add(new SqlParameter("name", profile.Name.ToSqlString())); paramz.Add(new SqlParameter("statusEnumId", profile.StatusId)); paramz.Add(new SqlParameter("comments", profile.Comment.ToSqlString())); paramz.Add(new SqlParameter("timeZoneOffset", profile.TimeZoneOffset.ToSqlString())); paramz.Add(new SqlParameter("smsAccoundSid", profile.SmsAccountSID.ToSqlString())); paramz.Add(new SqlParameter("smsAccountToken", profile.SmsAccountToken.ToSqlString())); paramz.Add(new SqlParameter("smsPhoneNumber", profile.SmsPhoneNumber.ToSqlString())); paramz.Add(new SqlParameter("emailConfigProfileId", profile.EmailConfigProfileId)); paramz.Add(new SqlParameter("emailConfigUserName", profile.EmailConfigUsername.ToSqlString())); paramz.Add(new SqlParameter("emailConfigPassword", profile.EmailConfigPassword.ToSqlString())); Func <SqlDataReader, int> readFx = (reader) => { return((int)reader["ChurchId"]); }; var church = _executor.ExecuteSql <int>("SaveChurchProfile", CommandType.StoredProcedure, paramz, readFx); profile.Id = church.FirstOrDefault(); Func <SqlDataReader, int> ciReadFx = (reader) => { return((int)reader["ContactInfoID"]); }; foreach (var addy in profile.AddressList) { commonRepository.MergeAddress(addy); } foreach (var addy in profile.PhoneList) { commonRepository.MergePhone(addy); } foreach (var addy in profile.EmailList) { commonRepository.MergeEmail(addy); } if (profile.PastoralTeam != null) { // save team paramz.Clear(); paramz.Add(new SqlParameter("id", profile.PastoralTeam.Id)); paramz.Add(new SqlParameter("name", profile.PastoralTeam.Name.ToSqlString())); paramz.Add(new SqlParameter("desc", profile.PastoralTeam.Desc.ToSqlString())); paramz.Add(new SqlParameter("churchId", profile.Id)); paramz.Add(new SqlParameter("teamTypeEnumId", profile.PastoralTeam.TeamTypeEnumId)); paramz.Add(new SqlParameter("comment", profile.PastoralTeam.Comment.ToSqlString())); readFx = (reader) => { return((int)reader["Id"]); }; var teamIds = _executor.ExecuteSql <int>("SaveTeam", CommandType.StoredProcedure, paramz, readFx); profile.PastoralTeam.Id = teamIds.FirstOrDefault(); // Save Teammates foreach (var teamMate in profile.PastoralTeam.Teammates) { teamMate.TeamId = profile.PastoralTeam.Id; paramz.Clear(); paramz.Add(new SqlParameter("@teammateId", teamMate.Id)); paramz.Add(new SqlParameter("@teamId", teamMate.TeamId)); paramz.Add(new SqlParameter("@entityId", teamMate.MemberId)); paramz.Add(new SqlParameter("@entityTypeEnumId", 56)); // person paramz.Add(new SqlParameter("@teamPositionEnumId", teamMate.TeamPositionEnumId)); var teammateIds = _executor.ExecuteSql <int>("SaveTeammate", CommandType.StoredProcedure, paramz, readFx); teamMate.Id = teammateIds.FirstOrDefault(); } } if (profile.Id != 0) { return(new RepositoryActionResult <ChurchProfile>(profile, RepositoryActionStatus.Updated)); } else { return(new RepositoryActionResult <ChurchProfile>(null, RepositoryActionStatus.NotFound)); } }
public ChurchProfile Get(int id) { ChurchProfile church = null; var proc = "GetChurchProfile"; using (var cn = new SqlConnection(_executor.ConnectionString)) using (var cmd = new SqlCommand(proc, cn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("churchId", id); cn.Open(); using (var reader = cmd.ExecuteReader()) { if (reader.HasRows) { reader.Read(); // member info church = new ChurchProfile(); church.Id = reader.ValueOrDefault <int>("ChurchId"); church.Name = reader.ValueOrDefault("ChurchName", string.Empty); church.StatusId = reader.ValueOrDefault <int>("StatusId", 0); church.StatusDesc = reader.ValueOrDefault("StatusDesc", string.Empty); church.Comment = reader.ValueOrDefault("Comment", string.Empty); church.TimeZoneOffset = reader.ValueOrDefault("TimeZoneOffset", string.Empty); church.SmsAccountSID = reader.ValueOrDefault("AccountSid", string.Empty); church.SmsAccountToken = reader.ValueOrDefault("AccountToken", string.Empty); church.SmsPhoneNumber = reader.ValueOrDefault("PhoneNumber", string.Empty); church.EmailConfigProfileId = reader.ValueOrDefault <int>("EmailConfigProfileId"); church.EmailConfigUsername = reader.ValueOrDefault <string>("EmailConfigUsername"); church.EmailConfigPassword = reader.ValueOrDefault <string>("EmailConfigPassword"); // address info reader.NextResult(); while (reader.Read()) { var addy = new Address(); addy.ContactInfoId = reader.ValueOrDefault <int>("ContactInfoID"); addy.ContactInfoType = reader.ValueOrDefault <int>("ContactInfoTypeEnumID"); addy.ContactInfoLocationType = reader.ValueOrDefault <int>("ContactInfoLocationTypeEnumID"); addy.Preferred = reader.ValueOrDefault <bool>("Preferred"); addy.Verified = reader.ValueOrDefault <bool>("Verified"); addy.Line1 = reader.ValueOrDefault <string>("Line1"); addy.Line2 = reader.ValueOrDefault <string>("Line2"); addy.Line3 = reader.ValueOrDefault <string>("Line3"); addy.City = reader.ValueOrDefault <string>("City"); addy.State = reader.ValueOrDefault <string>("State"); addy.Zip = reader.ValueOrDefault <string>("Zip"); church.AddressList.Add(addy); } // phone info reader.NextResult(); while (reader.Read()) { var addy = new Phone(); addy.ContactInfoId = reader.ValueOrDefault <int>("ContactInfoID"); addy.ContactInfoType = reader.ValueOrDefault <int>("ContactInfoTypeEnumID"); addy.ContactInfoLocationType = reader.ValueOrDefault <int>("ContactInfoLocationTypeEnumID"); addy.Preferred = reader.ValueOrDefault <bool>("Preferred"); addy.Verified = reader.ValueOrDefault <bool>("Verified"); addy.PhoneNumber = reader.ValueOrDefault <string>("Number"); addy.PhoneType = reader.ValueOrDefault <int>("PhoneTypeEnumID", 0); // cell phone, home phone, etc. church.PhoneList.Add(addy); } // email info reader.NextResult(); while (reader.Read()) { var addy = new Email(); addy.ContactInfoId = reader.ValueOrDefault <int>("ContactInfoID"); addy.ContactInfoType = reader.ValueOrDefault <int>("ContactInfoTypeEnumID"); addy.ContactInfoLocationType = reader.ValueOrDefault <int>("ContactInfoLocationTypeEnumID"); addy.Preferred = reader.ValueOrDefault <bool>("Preferred"); addy.Verified = reader.ValueOrDefault <bool>("Verified"); addy.EmailAddress = reader.ValueOrDefault <string>("Email"); church.EmailList.Add(addy); } // Pastoral Team members reader.NextResult(); while (reader.Read()) { Team pt = church.PastoralTeam; if (pt == null) { pt = new Team(); pt.Id = reader.ValueOrDefault <int>("TeamId"); pt.ChurchId = church.Id; pt.Name = reader.ValueOrDefault <string>("TeamName"); pt.Desc = reader.ValueOrDefault <string>("TeamDesc"); pt.TeamTypeEnumId = reader.ValueOrDefault <int>("TeamTypeEnumId"); church.PastoralTeam = pt; } var teammate = new Teammate(); teammate.Id = reader.ValueOrDefault <int>("TeammateId"); teammate.TeamId = reader.ValueOrDefault <int>("TeamId"); teammate.MemberId = reader.ValueOrDefault <int>("MemberId"); teammate.Name = reader.ValueOrDefault <string>("MemberName"); teammate.TeamPositionEnumId = reader.ValueOrDefault <int>("TeamPositionEnumId"); teammate.TeamPositionEnumDesc = reader.ValueOrDefault <string>("Position"); pt.Teammates.Add(teammate); } // attributes //reader.NextResult(); //while (reader.Read()) //{ // var attr = new CustomAttribute(); // attr.IdentityID = reader.ValueOrDefault<int>("IdentityID"); // attr.CustomAttrDefID = reader.ValueOrDefault<int>("CustomAttrDefID"); // attr.Value = reader.ValueOrDefault<string>("Value", string.Empty); // attr.Name = reader.ValueOrDefault<string>("CustomAttrName", string.Empty); // attr.DataType = reader.ValueOrDefault<string>("DataType", string.Empty); // attr.AttrTypeEnumID = reader.ValueOrDefault<int>("AttrTypeEnumID"); // attr.AttrTypeEnumDesc = reader.ValueOrDefault<string>("AttrTypeEnumDesc", string.Empty); // attr.IsEditable = reader.ValueOrDefault<bool>("IsEditable"); // member.CustomAttributeList.Add(attr); //} } } } return(church); }