public async void motivationLinesFromFile(List <string> motivationLines) { foreach (var line in motivationLines) { string[] splittedLine = line.Split('*'); string text = splittedLine[0]; string type = splittedLine[1]; string gender = splittedLine[2]; MotivationLine newMotivationLine = new MotivationLine(); newMotivationLine.Text = text; MotivationLineType motivationLineType; if (Enum.TryParse(type, out motivationLineType)) { newMotivationLine.MotivationLineType = motivationLineType; } else { throw new Exception("A motivationLineType in the textfile is not correct. maybe somewhere its club instead of Club"); } AttractedGender motivationLineGender; if (Enum.TryParse(gender, out motivationLineGender)) { newMotivationLine.AttractedGender = motivationLineGender; } else { throw new Exception("A motivationLineGender in the textfile is not correct. maybe somewhere its club instead of Club"); } await Database.SaveMotivationLineAsync(newMotivationLine); } }
private async void Save_Clicked(object sender, EventArgs e) { MotivationLine motivationLineItem = (MotivationLine)BindingContext; motivationLineItem.MotivationLineType = (MotivationLineType)Enum.Parse(typeof(MotivationLineType), (string)MotivationLineTypePicker.SelectedItem); await App.Database.SaveMotivationLineAsync(motivationLineItem); await Navigation.PopAsync(); }
private async void RemoveButton_Clicked(object sender, EventArgs e) { if (currentMotivationLine == null) { return; } LblCurrentMotivationLine.Text = "Druk op het mannetje!"; await App.Database.DeleteMotivationLineAsync(currentMotivationLine); currentMotivationLine = null; }
private async void EditButton_Clicked(object sender, EventArgs e) { if (currentMotivationLine == null) { return; } await Navigation.PushAsync(new MotivationLineCreatorPage() { BindingContext = currentMotivationLine }); LblCurrentMotivationLine.Text = "Druk op het mannetje!"; currentMotivationLine = null; }
private async Task TappedImage() { string motivationLineType = ""; if (MotivationLineTypePicker != null && MotivationLineTypePicker.SelectedItem != null) { motivationLineType = (string)MotivationLineTypePicker.SelectedItem; } MotivationLine filteredMotivationLine = await App.Database.GetMotivationLineByFilter(motivationLineType); if (currentMotivationLine != null && filteredMotivationLine != null) { if (filteredMotivationLine.Text.ToLower() == currentMotivationLine.Text.ToLower()) { var allMotivationLines = await App.Database.GetMotivationLinesAsync(); var otherMotivationLines = allMotivationLines.Where(p => p.Text.ToLower() != filteredMotivationLine.Text.ToLower()).ToList(); if (otherMotivationLines != null && otherMotivationLines.Count > 0) { if (otherMotivationLines.Count() == 1) { filteredMotivationLine = otherMotivationLines[0]; } else { filteredMotivationLine = otherMotivationLines[random.Next(0, otherMotivationLines.Count)]; } } } } if (filteredMotivationLine != null) { LblCurrentMotivationLine.Text = filteredMotivationLine.Text; currentMotivationLine = filteredMotivationLine; } else { LblCurrentMotivationLine.Text = "Geen motivatie zinnen gevonden!!"; } }