Esempio n. 1
0
        public async Task <ActionResult <Distantion> > PostDistantion(Distantion distantion)
        {
            _context.Distantion.Add(distantion);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetDistantion", new { id = distantion.IdDistantion }, distantion));
        }
Esempio n. 2
0
        public async Task <IActionResult> PutDistantion(int id, Distantion distantion)
        {
            if (id != distantion.IdDistantion)
            {
                return(BadRequest());
            }

            _context.Entry(distantion).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DistantionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task Update(int id)
        {
            if (Name_Entry.Text != null && Lengh_Entry.Text != null)
            {
                decimal lenght = Convert.ToDecimal(Lengh_Entry.Text);
                if (Discription_Editor.Text == null || Discription_Editor.Text == "")
                {
                    Discription_Editor.Text = "Описание отсутствует";
                }
                Distantion distantion = new Distantion
                {
                    IdDistantion   = id,
                    NameDistantion = Name_Entry.Text,
                    Lengs          = lenght,
                    Discriptions   = Discription_Editor.Text,
                };
                await distantionsServise.Update(distantion);

                await Navigation.PopModalAsync();
            }
            else
            {
                if (!await DisplayAlert("Ошибка", "Вы заполнили не все поля", "Заполнить", "Выйти"))
                {
                    await Navigation.PopModalAsync();
                }
            }
        }
Esempio n. 4
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;
            }
        }
        private async Task get_infa(int id)
        {
            Distantion distantion = await distantionsServise.Get_ID(id);

            if (id != 0)
            {
                Head_Lable.Text         = "Редактировать дистанцию";
                Name_Entry.Text         = distantion.NameDistantion;
                Lengh_Entry.Text        = distantion.Lengs.ToString();
                Discription_Editor.Text = distantion.Discriptions;
            }
        }
Esempio n. 6
0
        // добавляем одного друга
        public async Task <Distantion> Add(Distantion distantion)
        {
            HttpClient client   = getClientServise.GetClient();
            var        response = await client.PostAsync("http://90.189.158.10/api/Distantions/",
                                                         new StringContent(JsonConvert.SerializeObject(distantion), Encoding.UTF8, "application/json"));

            if (response.StatusCode != HttpStatusCode.OK)
            {
                return(null);
            }

            return(JsonConvert.DeserializeObject <Distantion>(await response.Content.ReadAsStringAsync()));
        }
        public async Task Criate()
        {
            if (Name_Entry.Text != null && Lengh_Entry.Text != null)
            {
                decimal lenght = Convert.ToDecimal(Lengh_Entry.Text);
                if (Discription_Editor.Text == null || Discription_Editor.Text == "")
                {
                    Discription_Editor.Text = "Описание отсутствует";
                }
                Distantion distantion = new Distantion
                {
                    NameDistantion = Name_Entry.Text,
                    Lengs          = lenght,
                    Discriptions   = Discription_Editor.Text,
                };
                await distantionsServise.Add(distantion);

                if (!await DisplayAlert("", "Добавить еще одну дистанцию", "Да", "Нет"))
                {
                    await Navigation.PopModalAsync();
                }
                else
                {
                    Name_Entry.Text         = null;
                    Discription_Editor.Text = null;
                    Lengh_Entry.Text        = null;
                }
            }
            else
            {
                if (!await DisplayAlert("Ошибка", "Вы заполнили не все поля", "Заполнить", "Выйти"))
                {
                    await Navigation.PopModalAsync();
                }
            }
        }