Beispiel #1
0
        async void OnSaveButtonClicked(object sender, EventArgs e)
        {
            var entry = viewModel.Entry;

            var entryVersion = new EntryVersion
            {
                EntryId        = entry.Id,
                TextEntry      = entryText.Text,
                ModifyReason   = modifyReason.Text,
                VersionTrackId = entry.EntryVersion.VersionTrackId
            };

            entry.EntryVersion = entryVersion;

            if (entryVersion.ModifyReason != null && entryVersion.TextEntry != null)
            {
                entry.EntryVersion.VersionTrackId = entry.EntryVersion.VersionTrackId + 1;

                MessagingCenter.Send(this, "EditEntry", entry);
                await Navigation.PopAsync();
            }
            else
            {
                if (entryVersion.ModifyReason == null)
                {
                    await DisplayAlert("Error", "The modification reason can't be empty!", "Try again");
                }
                else if (entryVersion.TextEntry == null)
                {
                    await DisplayAlert("Error", "The entry text can't be empty!", "Try again");
                }
            }
        }
        async void OnSaveButtonClicked(object sender, EventArgs e)
        {
            var entry = new Entry
            {
                Title    = newEntryTitle.Text,
                Location = newEntryLocation.Text
            };

            var entryVersion = new EntryVersion
            {
                VersionTrackId = 1,
                TextEntry      = newEntryText.Text
            };

            entry.EntryVersion = entryVersion;

            if (entry.Title != null && entry.Location != null && entryVersion.TextEntry != null)
            {
                MessagingCenter.Send(this, "AddEntry", entry);
                await Navigation.PopAsync();
            }
            else
            {
                if (entry.Title == null)
                {
                    await DisplayAlert("Error", "The entry title can't be empty!", "Try again");
                }
                else if (entry.Location == null)
                {
                    await DisplayAlert("Error", "The current location can't be empty!", "Try again");
                }
                else if (entryVersion.TextEntry == null)
                {
                    await DisplayAlert("Error", "The entry text can't be empty!", "Try again");
                }
            }
        }