public async Task UpdateEvent(Event @event) { IsBusy = true; bool eventFound = false; if (Global.GlobalREICTModel.Events.Count() > 0) { foreach (Event @Event in Global.GlobalREICTModel.Events) { if (@event.Id == @Event.Id) { @Event.Colour = @event.Colour; @Event.IsVisible = @event.IsVisible; @Event.FirstRespondent = @event.FirstRespondent; @Event.SecondRespondent = @event.SecondRespondent; @Event.ThirdRespondent = @event.ThirdRespondent; eventFound = true; } } } if (!eventFound) Global.GlobalREICTModel.Events.Add(@event); SetRespondents(@event); await FirebaseDBBase.UpdateEventAsync(Global.GlobalREICTModel); IsBusy = false; }
public async Task UpdateEvent(Event @event) { IsBusy = true; bool eventFound = false; @event.Name = RemoveFormatEventName(@event.Name, @event.Time); if (Global.GlobalREICTModel.Events.Count() > 0) { foreach (Event @Event in Global.GlobalREICTModel.Events) { if (@event.Id == @Event.Id) { @Event.Name = @event.Name; @Event.Colour = @event.Colour; @Event.IsVisible = @event.IsVisible; @Event.FirstRespondent = @event.FirstRespondent; @Event.SecondRespondent = @event.SecondRespondent; @Event.ThirdRespondent = @event.ThirdRespondent; @Event.AlarmSet = @event.AlarmSet; @Event.AlarmText = @event.AlarmText; eventFound = true; } } } if (!eventFound) { Global.GlobalREICTModel.Events.Add(@event); } CleanEventName(); await FirebaseDBBase.UpdateEventAsync(Global.GlobalREICTModel); IsBusy = false; }
// Simulates background work that happens behind the splash screen void SimulateStartup() { Log.Debug(TAG, "Performing some startup work that takes a bit of time."); //await Task.Delay(8000); // Simulate a bit of startup work. FirebaseDBBase.GetItemsAsync(false).ConfigureAwait(false); Log.Debug(TAG, "Startup work is finished - starting MainActivity."); StartActivity(new Intent(Application.Context, typeof(MainActivity))); }
public EventsViewModel() { Title = string.Format("Top {0} Current Events", Global.NumberOfEvents + 1); Events = new ObservableCollection <Event>(); LoadEventsCommand = new Command(async() => ExecuteLoadEventsCommand()); iEvents = 0; MessagingCenter.Subscribe <NewEventPage, Event>(this, "AddEvent", async(obj, @event) => { var newEvent = @event as Event; Events.Add(newEvent); Global.GlobalREICTModel.Events.Add(@event); await FirebaseDBBase.AddItemAsync(Global.GlobalREICTModel); }); }
private async void BtnAdd_Clicked(object sender, EventArgs e) { bool personExists = false; foreach (var person in Global.GlobalREICTModel.Persons) { if (person.CellNumber == txtCellNumber.Text) { SelectedPerson = person; person.Name = txtName.Text; person.Surname = txtSurname.Text; person.CellNumber = txtCellNumber.Text; person.PersonID = Guid.NewGuid().ToString(); person.Password = txtPassword.Text; person.Role.Name = lstRole.SelectedItem.ToString(); personExists = true; break; } } if (!personExists) { var newPerson = new Person { Name = txtName.Text, Surname = txtSurname.Text, CellNumber = txtCellNumber.Text, PersonID = Guid.NewGuid().ToString(), Password = txtPassword.Text }; var role = new Role { RoleID = Guid.NewGuid().ToString(), Name = lstRole.SelectedItem.ToString() }; newPerson.Role = role; Global.GlobalREICTModel.Persons.Add(newPerson); } await FirebaseDBBase.UpdatePersonAsync(Global.GlobalREICTModel); ClearForm(); }