private void InitBtnClickListeners() { btnDate.Click += (sender, e) => { ShowDateTimeDialog(); }; btnAddUser.Click += (sender, e) => { ChooseGroupDialog(); }; btnCreate.Click += async(sender, e) => { sportEvent.Creator = new User(Instance.User); sportEvent.AddUser(Instance.User); sportEvent.Location = editLocation.Text; var addEventTask = DatabaseManager.AddSportEvent(sportEvent); await addEventTask.ConfigureAwait(true); if (addEventTask.IsCompletedSuccessfully) { var snapshot = await DatabaseManager.GetSportEvents(sportEvent) .ConfigureAwait(true); Instance.Events.Add(snapshot.ToObjects <SportEvent>().FirstOrDefault()); Toast.MakeText(view.Context, Resource.String.info_firestore_success, ToastLength.Short) .Show(); } else { Toast.MakeText(view.Context, Resource.String.err_failed_to_save_firestore, ToastLength.Short) .Show(); } }; spSports.ItemSelected += (sender, e) => { string item = (string)spSports.GetItemAtPosition(e.Position); sportEvent.EventType = (SportType)Enum.Parse(typeof(SportType), item); }; }
private async void TEST() { // for testing SportEvent sevent = new SportEvent() { Date = DateTime.Now, Location = "Iza moje kuce 46", EventType = SportType.Basketball, Creator = Instance.User }; sevent.AddUser(new User("Josip", "*****@*****.**")); sevent.AddUser(new User("Toki", "*****@*****.**")); sevent.AddUser(new User("Karlo", "*****@*****.**")); sevent.AddUser(new User("Zvonki", "*****@*****.**")); sevent.AddUser(new User("Karlo", "*****@*****.**")); sevent.AddUser(Instance.User); //await DatabaseManager.AddSportEvent(sevent).ConfigureAwait(false); }