private async void lstData_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            if (e.SelectedItem != null)
            {
                string obj = e.SelectedItem.ToString();
                obj = obj.Substring(obj.LastIndexOf(',') + 1).Replace("IdParticipation = ", string.Empty).Replace("}", string.Empty);
                string res = await DisplayActionSheet("Выберите операцию", "Отмена", null, "Отказаться от участия в соревнование", "Получить бэйдж");

                switch (res)
                {
                case "Отказаться от участия в соревнование":
                    InfoUser loginUsers = await loginUsersService.Get(App.Current.Properties["token"].ToString());

                    IEnumerable <InfoUser> infoUsers = await registrationUsersService.Get_user();

                    IEnumerable <CategoriYars> categoriYars = await categoriYarsServise.Get();

                    IEnumerable <Participation> participations = await participationService.Get();

                    IEnumerable <Distantion> distantions = await distantionsServise.Get();

                    IEnumerable <Competentions> competentions = await competentionsServise.Get();

                    var info = from p in participations
                               join k in competentions on p.IdCompetentions equals k.IdCompetentions
                               join d in distantions on k.IdDistantion equals d.IdDistantion
                               join i in infoUsers on p.IdUser equals i.IdUsers
                               select new
                    {
                        i.IdUsers,
                        k.Date,
                        p.IdStatusVerification,
                        d.NameDistantion,
                        p.IdParticipation
                    };
                    info = info.Where(x => x.IdUsers == loginUsers.IdUsers);
                    var picker_list = info.FirstOrDefault(x => x.IdParticipation == Convert.ToInt32(obj));

                    if (picker_list.Date <= DateTime.Today.AddDays(2))
                    {
                        await DisplayAlert("Уведомление", "К сожалению отказаться от участия уже нельзя", "Ok");
                    }
                    else
                    {
                        await participationService.Delete(Convert.ToInt32(obj));
                        await showEmployeeAsync(false);
                        await DisplayAlert("Уведомление", "Вы успешно отказались от участия", "Ok");
                    }

                    break;

                case "Получить бэйдж":
                    await DownloadBage(Convert.ToInt32(obj));

                    break;
                }
                lstData.SelectedItem = null;
            }
        }
Пример #2
0
        private async void lstData_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            if (e.SelectedItem != null)
            {
                Distantion obj = (Distantion)e.SelectedItem;
                string     res = await DisplayActionSheet("Выберите операцию", "Отмена", null, "Обновить данные", "Удалить данные");

                switch (res)
                {
                case "Обновить данные":
                    await Navigation.PushModalAsync(new AddDistantionsPage(obj.IdDistantion), animate);

                    break;

                case "Удалить данные":
                    bool result = await DisplayAlert("Подтвердить действие", "Вы хотите удалить элемент?", "Да", "Нет");

                    if (result == true)
                    {
                        Distantion Del_Distantion = await distantionsServise.Delete(obj.IdDistantion);

                        IEnumerable <Competentions> competentions = await competentionsServise.Get();

                        var selectad_del_compitentions = competentions.FirstOrDefault(p => p.IdDistantion == obj.IdDistantion);
                        if (selectad_del_compitentions != null)
                        {
                            Competentions Del_compitentions = await competentionsServise.Delete(selectad_del_compitentions.IdCompetentions);

                            IEnumerable <Participation> participations = await participationService.Get();

                            var selectad = participations.FirstOrDefault(p => p.IdCompetentions == selectad_del_compitentions.IdCompetentions);
                            if (selectad != null)
                            {
                                int id_part = selectad.IdParticipation;
                                IEnumerable <ResultParticipant> res_participations = await resultParticipationServise.Get();

                                Participation Del_Participation = await participationService.Delete(id_part);

                                var res_selectad = res_participations.FirstOrDefault(p => p.IdParticipation == id_part);
                                if (res_selectad != null)
                                {
                                    int id_res_part = res_selectad.IdResultParticipation;
                                    ResultParticipant Del_ResultPartisipation = await resultParticipationServise.Delete(id_res_part);
                                }
                            }
                        }
                        await showEmployeeAsync();
                        await DisplayAlert("Уведомление", "Дистанция успешно удалена", "Ok");
                    }
                    break;
                }
                lstData.SelectedItem = null;
            }
        }
Пример #3
0
        private async void lstData_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            if (e.SelectedItem != null)
            {
                string obj = e.SelectedItem.ToString();
                obj = obj.Substring(obj.LastIndexOf(',') + 1).Replace("IdCompetentions = ", string.Empty).Replace("}", string.Empty);

                string res = await DisplayActionSheet("Выберите операцию", "Отмена", null, "Обновить данные", "Удалить данные");

                switch (res)
                {
                case "Обновить данные":
                    await Navigation.PushModalAsync(new AddCompitentionsPage(Convert.ToInt32(obj)), animate);

                    break;

                case "Удалить данные":
                    bool result = await DisplayAlert("Подтвердить действие", "Вы хотите удалить элемент?", "Да", "Нет");

                    if (result == true)
                    {
                        IEnumerable <Participation> participations = await participationService.Get();

                        Competentions Del_compitentions = await competentionsServise.Delete(Convert.ToInt32(obj));

                        var selectad = participations.FirstOrDefault(p => p.IdCompetentions == Convert.ToInt32(obj));
                        if (selectad != null)
                        {
                            int id_part = selectad.IdParticipation;
                            IEnumerable <ResultParticipant> res_participations = await resultParticipationServise.Get();

                            Participation Del_Participation = await participationService.Delete(id_part);

                            var res_selectad = res_participations.FirstOrDefault(p => p.IdParticipation == id_part);
                            if (res_selectad != null)
                            {
                                int id_res_part = res_selectad.IdResultParticipation;
                                ResultParticipant Del_ResultPartisipation = await resultParticipationServise.Delete(id_res_part);
                            }
                        }
                        await showEmployeeAsync(false);
                        await DisplayAlert("Уведомление", "Компетенция успешно удалена", "Ok");
                    }
                    break;
                }
                lstData.SelectedItem = null;
            }
        }
        private async void lstData_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            if (e.SelectedItem != null)
            {
                string obj = e.SelectedItem.ToString();
                obj = obj.Substring(obj.LastIndexOf(',') + 1).Replace("IdParticipation = ", string.Empty).Replace("}", string.Empty);
                string res = await DisplayActionSheet("Выберите операцию", "Отмена", null, "Подробнее", "Обновить данные", "Удалить данные");

                switch (res)
                {
                case "Подробнее":
                    await PopupNavigation.Instance.PushAsync(new MoreInfoParticipationsPage());

                    break;

                case "Обновить данные":
                    await Navigation.PushModalAsync(new AddPaticipationsPage(Convert.ToInt32(obj)), animate);

                    break;

                case "Удалить данные":
                    bool result = await DisplayAlert("Подтвердить действие", "Вы хотите удалить элемент?", "Да", "Нет");

                    if (result == true)
                    {
                        IEnumerable <ResultParticipant> participations = await resultParticipationServise.Get();

                        var           selectad          = participations.FirstOrDefault(p => p.IdParticipation == Convert.ToInt32(obj));
                        Participation Del_Participation = await participationService.Delete(Convert.ToInt32(obj));

                        if (selectad != null)
                        {
                            ResultParticipant Del_ResultPartisipation = await resultParticipationServise.Delete(selectad.IdResultParticipation);
                        }
                        await showEmployeeAsync(false);
                        await DisplayAlert("Уведомление", "Соревнование удалено", "Ok");
                    }
                    break;
                }
                lstData.SelectedItem = null;
            }
        }