Exemplo n.º 1
0
        private async void ExecuteTapCommand(object obj)
        {
            CalendarInlineEvent appointment = (CalendarInlineEvent)obj;

            int   idx        = Appointments.IndexOf(appointment);
            Event detailInfo = Events[idx];

            string message = $"{detailInfo.Description}\n" +
                             $"From: {appointment.StartTime.ToShortTimeString()}\n" +
                             $"To: {appointment.EndTime.ToShortTimeString()}\n" +
                             $"Location: {detailInfo.Location}";

            var more = await _pageDialog.DisplayAlertAsync(detailInfo.Title, message, "More", "Ok");

            if (more)
            {
                string action = await _pageDialog.DisplayActionSheetAsync("What would you like to do?", "Cancel", null, "Edit", "Delete");

                if (action == "Delete")
                {
                    await _apiManager.DeleteEvent(Config.Token, detailInfo.Code);

                    Appointments.RemoveAt(idx);
                }
                else if (action == "Edit")
                {
                    var navigationParams = new NavigationParameters();
                    navigationParams.Add("event", detailInfo);
                    await _navigationService.NavigateAsync(new Uri(NavigationConstants.CalendarEditPage, UriKind.Relative), navigationParams);
                }
            }
        }