protected override Church Parse() { return(new Church { Id = ToInt(SimbahanID), StreetNumber = ToInt(StreetNo), StreetName = StreetName.ToString(), Barangay = Barangay.ToString(), StateProvince = StateOrProvince.ToString(), City = City.ToString(), ZipCode = ZipCode.ToString(), CompleteAddress = CompleteAddress.ToString(), Diocese = Diocese.ToString(), Parish = Parish.ToString(), Priest = ParishPriest.ToString(), Vicariate = Vicariate.ToString(), DateEstablished = DateEstablished.ToString(), LastUpdate = ToDateTime(LastUpdate), FeastDay = FeastDay.ToString(), ContactNo = ContactNo.ToString(), Latitude = ToDouble(Latitude), Longitude = ToDouble(Longitude), HasAdorationChapel = ToBoolean(HasAdorationChapel), ChurchHistory = ChurchHistory.ToString(), OfficeHours = OfficeHours.ToString(), ChurchTypeId = ToInt(ChurchTypeID), Website = Website.ToString(), EmailAddress = EmailAddress.ToString(), DevotionSchedule = DevotionSchedule.ToString(), LocationId = ToInt(LocationID), ChurchCode = ChurchCode.ToString() }); }
void SetModel(ProfileModel profile) { model = profile; viewModel.DioceseList = structureController.Structure?.Dioceses?.Values.ToList(); viewModel.FunctionList = structureController.Structure?.Functions?.Values.ToList(); if (profile == null) { return; } viewModel.Firstname = profile.Firstname; viewModel.Lastname = profile.Lastname; viewModel.Residence = profile.Residence; viewModel.Phone = profile.Phone; viewModel.Mail = profile.Mail; viewModel.WoodbadgeCount = profile.WoodbadgeCount; viewModel.FavouriteStage = profile.FavouriteStage; viewModel.RelationshipStatus = profile.RelationshipStatus; viewModel.Association = profile.Association; viewModel.IsPriest = profile.IsPriest; if (profile.GeorgesPoints < 0) { viewModel.GeorgesPoints = ""; } else { viewModel.GeorgesPoints = profile.GeorgesPoints.ToString(); } if (!String.IsNullOrEmpty(profile.DioceseId)) { Diocese diocese = structureController.Structure.Dioceses[profile.DioceseId]; viewModel.SelectedDiocese = diocese; if (diocese.HasRegions) { if (!String.IsNullOrEmpty(profile.RegionId)) { Region region = diocese?.Regions[profile.RegionId]; viewModel.SelectedRegion = region; if (!String.IsNullOrEmpty(profile.TribeId)) { Tribe tribe = region?.Tribes[profile.TribeId]; viewModel.SelectedTribe = tribe; } } } else { viewModel.SelectedRegion = null; if (!String.IsNullOrEmpty(profile.TribeId)) { Tribe tribe = diocese?.Tribes[profile.TribeId]; viewModel.SelectedTribe = tribe; } } } if (!String.IsNullOrEmpty(profile.FunctionId)) { viewModel.SelectedFunction = structureController.Structure.Functions[profile.FunctionId]; } if (String.IsNullOrEmpty(profile.ImageId)) { viewModel.Image = ImageSource.FromFile("avatar.jpg"); } else { imageApi.Get(profile.ImageId).Subscribe(image => { viewModel.Image = ImageSource.FromStream(() => new MemoryStream(image.Bytes)); }, cts.Token); } }
private void SetModel(ProfileModel model) { profile = model; if (profile == null) { return; } if (ctsSecondary != null) { ctsSecondary.Cancel(); } ctsSecondary = new CancellationTokenSource(); viewModel.IsDataLoaded = true; viewModel.IsMyProfile = (model.Id == authController.AuthToken.UserId); viewModel.IsBookmarked = bookmarkController.IsBookmarked(model.Id); viewModel.Name = model.Name; viewModel.Firstname = model.Firstname; viewModel.Lastname = model.Lastname; viewModel.Residence = model.Residence; viewModel.Phone = model.Phone; viewModel.Mail = model.Mail; viewModel.WoodbadgeCount = model.WoodbadgeCount; viewModel.FavouriteStage = model.FavouriteStage; viewModel.RelationshipStatus = model.RelationshipStatus; viewModel.ShowContact = !(string.IsNullOrEmpty(viewModel.Phone) && string.IsNullOrEmpty(viewModel.Mail)); if (model.GeorgesPoints < 0) { viewModel.GeorgesPoints = ""; } else { viewModel.GeorgesPoints = model.GeorgesPoints.ToString(); } if (!String.IsNullOrEmpty(model.DioceseId)) { Diocese diocese = structureController.Structure.Dioceses[model.DioceseId]; viewModel.Diocese = diocese; if (diocese.HasRegions) { if (!String.IsNullOrEmpty(model.RegionId)) { Region region = diocese?.Regions[model.RegionId]; viewModel.Region = region; if (!String.IsNullOrEmpty(model.TribeId)) { Tribe tribe = region?.Tribes[model.TribeId]; viewModel.Tribe = tribe; } } } else { viewModel.Region = null; if (!String.IsNullOrEmpty(model.TribeId)) { Tribe tribe = diocese?.Tribes[model.TribeId]; viewModel.Tribe = tribe; } } } if (!String.IsNullOrEmpty(model.FunctionId)) { viewModel.Function = structureController.Structure.Functions[model.FunctionId]; } if (!String.IsNullOrEmpty(model.ImageId)) { imageApi.Get(model.ImageId).Subscribe(image => { viewModel.Image = ImageSource.FromStream(() => new MemoryStream(image.Bytes)); }, ctsSecondary.Token); } adventureApi.Get(profile.Id).Subscribe(adventures => { if (ctsAdventureProfiles != null) { ctsAdventureProfiles.Cancel(); } ctsAdventureProfiles = new CancellationTokenSource(); viewModel.ShowAdventures = true; viewModel.Adventures.Clear(); float adventurePoints = 0; foreach (AdventureModel adventure in adventures) { if (adventure.WithUserId == authController.AuthToken.UserId && adventure.WithConfirmed) { viewModel.ShowAdventureButton = false; } if (adventure.Confirmed && adventure.WithConfirmed) { // adventure confirmed from both users => show on profile page AdventureViewModel adventureViewModel = new AdventureViewModel(); adventureViewModel.Label = adventure.WithUserId; adventureViewModel.Points = adventure.Points.ToString(); viewModel.Adventures.Add(adventureViewModel); adventurePoints += adventure.Points; profileApi.Get(adventure.WithUserId).Subscribe(withProfile => { adventureViewModel.Label = withProfile.Name; if (!string.IsNullOrEmpty(withProfile.ImageId)) { imageApi.Get(withProfile.ImageId).Subscribe(image => { adventureViewModel.Image = ImageSource.FromStream(() => new MemoryStream(image.Bytes)); }, ctsAdventureProfiles.Token); } }, ctsAdventureProfiles.Token); } } int adventureCount = viewModel.Adventures.Count; FormattedString pointsText = new FormattedString(); pointsText.Spans.Add(new Span { Text = profile.Firstname, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }); pointsText.Spans.Add(new Span { Text = " hat insgesamt ", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }); pointsText.Spans.Add(new Span { Text = adventurePoints.ToString(), FontSize = 60, FontAttributes = FontAttributes.Bold, TextColor = Color.SteelBlue }); pointsText.Spans.Add(new Span { Text = " Punkte bei " + adventureCount.ToString() + " Abenteuer" + (adventureCount > 1 ? "n" : "") + " gesammelt", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }); viewModel.AdventurePoints = pointsText; if (viewModel.Adventures.Count > 0) { viewModel.ShowAdventures = true; // resize the listview to match content adventuresList.HeightRequest = adventuresList.RowHeight * Math.Min(viewModel.Adventures.Count, MAX_ADVENTURES); } }, ctsSecondary.Token); profileApi.Get(authController.AuthToken.UserId).Subscribe(async myProfile => { this.myProfile = myProfile; float possiblePoints = await CalculatePointsAsync(myProfile, profile); FormattedString hint = new FormattedString(); hint.Spans.Add(new Span { Text = possiblePoints.ToString(), FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), FontAttributes = FontAttributes.Bold }); hint.Spans.Add(new Span { Text = " Punkte bekommst du für ein Abenteuer mit " }); hint.Spans.Add(new Span { Text = model.Firstname }); viewModel.PossiblePoints = hint; }, ctsSecondary.Token); }