async Task OnTaskAdd(object sender, EventArgs args, Button butt, competitionCreationSeed seed) { seed.eventName = eventName.Text; seed.startDate = startDate.Date; seed.endDate = endDate.Date; seed.description = description.Text; seed.SetLiveType(LiveType.SelectedItem.ToString()); await Navigation.PushAsync(new TaskCreation(seed)); }
bool MeetsCriteria(competitionCreationSeed seed) { try { if (eventName.Text.Length >= 3 && description.Text.Length >= 6 && endDate.Date >= startDate.Date && seed.Tasks.Count >= 3) { return(true); } return(false); } catch { return(false); } }
async Task OnButtonClicked(object sender, EventArgs args, Button butt, competitionCreationSeed seed) { if (!MeetsCriteria(seed)) { errorLabel.IsVisible = true; } else { int type = LiveType.SelectedIndex; Assets.Competition comp = new Assets.Competition(0, eventName.Text, startDate.Date, endDate.Date, description.Text, type, Session.Id); int compIndex = MySQLManager.InsertCompetition(comp); foreach (var item in seed.Tasks) { item.fk_Competition_id = compIndex; MySQLManager.InsertTask(item); } await Navigation.PushAsync(new HomePage()); } }
public CompetitionCreation(competitionCreationSeed seed) { Button CreationButton = new Button { Text = "Create", BackgroundColor = Color.White, BorderColor = Color.Black, BorderWidth = 3, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; Button TaskAddButton = new Button { Text = "Add Task", BackgroundColor = Color.White, BorderColor = Color.Black, BorderWidth = 3, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; eventName = new Entry { Text = seed.eventName, Placeholder = "Atleast 3 characters", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; startDate = new DatePicker { Date = seed.startDate, MinimumDate = DateTime.Now, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; endDate = new DatePicker { Date = seed.endDate, MinimumDate = DateTime.Now, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; description = new Entry { Text = seed.description, Placeholder = "Describe your competition", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; LiveType = new Picker { WidthRequest = 100, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; errorLabel = new Label { IsVisible = false, Text = "Something went wrong, make sure your inputs meet the criteria", TextColor = Color.Red, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; errorLabel2 = new Label { IsVisible = false, Text = "This email is already registered", TextColor = Color.Red, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; TaskCount = new Label { Text = seed.Tasks.Count.ToString(), HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; CreationButton.Clicked += async(sender, args) => await OnButtonClicked(sender, args, CreationButton, seed); TaskAddButton.Clicked += async(sender, args) => await OnTaskAdd(sender, args, TaskAddButton, seed); LiveType.Items.Add("Yes"); LiveType.Items.Add("No"); LiveType.SelectedIndex = seed.LiveType; ScrollView scrollView = new ScrollView { VerticalOptions = LayoutOptions.FillAndExpand, Content = new StackLayout { Children = { new Label { Text = "Competition name:*", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }, eventName, new Label { Text = "Starting date:*", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }, startDate, new Label { Text = "Ending date (same as start for endless):", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }, endDate, new Label { Text = "Description:*", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }, description, new Label { Text = "Is this event Live?*", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }, LiveType, new Label { Text = "Task count:*", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }, TaskCount, TaskAddButton, CreationButton, errorLabel, errorLabel2 } } }; Content = scrollView; }
private async void NavigateButton_OnClickedInLogin(object sender, EventArgs e, Button butt, competitionCreationSeed seed, Map map) { if (Crit()) { seed.AddTask(GetTaskObject(map)); await Navigation.PushAsync(new CompetitionCreation(seed)); } else { errorLabel.IsVisible = true; } }
public TaskCreation(competitionCreationSeed seed) { Button butt = new Button { Text = "Add", BackgroundColor = Color.White, BorderColor = Color.Black, BorderWidth = 3, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; errorLabel = new Label { IsVisible = false, Text = "Something went wrong, check your credentials", TextColor = Color.Red, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; taskName = new Entry { Placeholder = "Enter task name", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; Description = new Entry { Placeholder = "Describe the task", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, }; Question = new Entry { Placeholder = "Question", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, }; Answer = new Entry { Placeholder = "Correct answer", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, }; Map map = new Map(); butt.Clicked += async(sender, args) => NavigateButton_OnClickedInLogin(sender, args, butt, seed, map); ScrollView scrollView = new ScrollView { VerticalOptions = LayoutOptions.FillAndExpand, Content = new StackLayout { Children = { new Label { Text = "Task Creation", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.StartAndExpand }, taskName, Description, Question, Answer, map, butt, errorLabel } } }; Content = scrollView; }