示例#1
0
        public MainViewAdress()
        {
            var adress = new AdresService();

            AdressList = adress.GetAdress();
            VoteUp     = new Command <postVM>((model) => {
                AdressList[AdressList.IndexOf(model)].Vote++;
                AdressList.Add(new postVM
                {
                    Date      = new DateTime(2019, 12, 27),
                    Photo     = ImageSource.FromResource("HackUpp.images.coronavirus.jpg"),
                    Title     = "COVID-18",
                    Publisher = new User()
                    {
                        PhotoProfil = ImageSource.FromResource("HackUpp.images.fekiyoussef.png"),
                        Username    = "******",
                        Sid9        = 9
                    },
                    Vote        = 500,
                    Description = "https://www.who.int/fr/emergencies/diseases/novel-coronavirus-2019 \n" +
                                  "https://www.who.int/fr/emergencies/diseases/novel-coronavirus-2019/advice-for-public",
                    Subtitle = "Le premier infecterpar un nouveautype de coronavirus qui apparut de nouveau dans le monde. Un grand risque d'aprés l'Organisation mondiale de santé"
                });
                AdressList = AdressList;
            });
            VoteDown = new Command <postVM>((model) => {
                AdressList[AdressList.IndexOf(model)].Vote--;
            });
        }
示例#2
0
        private static HttpResponseMessage GetMethod(string patch)
        {
            HttpClient client = AdressList.GetHttpClient();

            AdminAuthorization.SetAuthorization(client);
            return(client.GetAsync(patch).Result);
        }
        public void BookingSeats(Seance seance, ArrayList numbers)
        {
            string myContent = JsonConvert.SerializeObject(new
            {
                seanceId      = (string)seance.GetId().ToString(),
                reservedSeats = numbers,
            });

            DialogMessage.ShowInfo("Post: " + myContent);
            var content = new StringContent(myContent, Encoding.UTF8, "application/json");

            HttpClient client = AdressList.GetHttpClient();

            AdminAuthorization.SetAuthorization(client);
            HttpResponseMessage response = client.PostAsync(AdressList.Booking, content).Result;

            if (response.StatusCode == HttpStatusCode.Created)
            {
                NotifitactionForm.ShowMessage("Wysłany element: " + "Rezerwacja");
            }
            else
            {
                DialogMessage.ShowInfo("Błąd wysyłania elementu: " + "Rezerwacja");
            }
        }
示例#4
0
        public static bool SingIn(AuthData user)
        {
            var content = ContentCreator.CreateContent(user);
            HttpResponseMessage response = AdressList.GetHttpClient().PostAsync(AdressList.SingIn, content).Result;

            if (response.StatusCode == HttpStatusCode.OK)
            {
                MainUserCreator.PutUserToSystem(response);
                SaveService.SaveUser(user);
                return(true);
            }
            DialogMessage.ShowInfo("Logowanie nieudane!");
            return(false);
        }
示例#5
0
        public static bool SingUp(AuthData user)
        {
            var content = ContentCreator.CreateContent(user);
            HttpResponseMessage response = AdressList.GetHttpClient().PostAsync(AdressList.SingUp, content).Result;

            if (response.StatusCode == HttpStatusCode.Created)
            {
                NotifitactionForm.ShowMessage("Użytkownik zarejestrowany!");
                return(true);
            }

            DialogMessage.ShowInfo("Rejestracja nieudana!");
            return(false);
        }
        private static void PostMethod(string patch, dynamic content, string name)
        {
            HttpClient client = AdressList.GetHttpClient();

            AdminAuthorization.SetAuthorization(client);
            HttpResponseMessage response = client.PostAsync(patch, content).Result;

            if (response.StatusCode == HttpStatusCode.Created)
            {
                NotifitactionForm.ShowMessage("Wysłany element: " + name);
            }
            else
            {
                DialogMessage.ShowInfo("Błąd wysyłania elementu: " + name);
            }
        }
示例#7
0
        private static void DeleteMethod(string patch, int id, string name)
        {
            HttpClient client = AdressList.GetHttpClient();

            AdminAuthorization.SetAuthorization(client);
            string url = patch + "/" + id;
            HttpResponseMessage response = client.DeleteAsync(url).Result;

            if (response.StatusCode == HttpStatusCode.NoContent)
            {
                NotifitactionForm.ShowMessage("Usunięty element: " + name);
            }
            else
            {
                DialogMessage.ShowInfo("Błąd usuwania elemntu: " + name);
            }
        }
        public void SendComment(Comment comment)
        {
            HttpClient client = AdressList.GetHttpClient();

            AdminAuthorization.SetAuthorization(client);
            var content = ContentCreator.CreateContent(comment);
            HttpResponseMessage response = client.PostAsync(AdressList.Comments, content).Result;

            if (response.StatusCode == HttpStatusCode.Created)
            {
                NotifitactionForm.ShowMessage("Wysłany element: " + "Komentarz");
            }
            else
            {
                DialogMessage.ShowInfo("Błąd wysyłania elementu: " + "Komentarz");
            }
        }
        public static void ChangeUserRole(User user)
        {
            HttpClient client = AdressList.GetHttpClient();

            AdminAuthorization.SetAuthorization(client);
            string patchUrl = AdressList.UsersAdmin + user.GetId() + "/update-role";
            var    content  = ContentCreator.CreateContent(user.GetRole());
            HttpResponseMessage response = client.SendAsync(new HttpRequestMessage(new HttpMethod("PATCH"), patchUrl)
            {
                Content = content
            }).Result;

            if (response.StatusCode != HttpStatusCode.OK)
            {
                DialogMessage.ShowInfo("Problem ze zmianą statusu!");
            }
            else
            {
                NotifitactionForm.ShowMessage("Status zmieniony!");
            }
        }
        public static void BanUser(User user)
        {
            HttpClient client = AdressList.GetHttpClient();

            AdminAuthorization.SetAuthorization(client);
            string patchUrl = AdressList.UsersAdmin + user.GetId() + "/ban";
            HttpResponseMessage response = client.SendAsync(new HttpRequestMessage(new HttpMethod("PATCH"), patchUrl)).Result;

            if (response.StatusCode != HttpStatusCode.NoContent)
            {
                DialogMessage.ShowInfo("Problem z banowaniem!");
            }
            else if (response.StatusCode == HttpStatusCode.Forbidden)
            {
                DialogMessage.ShowInfo("Nie można banować administratorów!");
            }
            else
            {
                NotifitactionForm.ShowMessage("Użytkownik zbanowany!");
            }
        }
        public static void ChangeArticleStatus(Article article)
        {
            HttpClient client = AdressList.GetHttpClient();

            AdminAuthorization.SetAuthorization(client);

            string patchUrl = AdressList.ArticlesAdmin + "/" + article.GetId() + "/status";
            var    content  = ContentCreator.CreateContent(article.GetStatus());
            HttpResponseMessage response = client.SendAsync(new HttpRequestMessage(new HttpMethod("PATCH"), patchUrl)
            {
                Content = content
            }).Result;

            if (response.StatusCode != HttpStatusCode.OK)
            {
                DialogMessage.ShowInfo("Błąd zmiany statusu!");
            }
            else
            {
                NotifitactionForm.ShowMessage("Status zmieniony!");
            }
        }
示例#12
0
 private static HttpResponseMessage GetFromServer(string adress)
 {
     return(AdressList.GetHttpClient().GetAsync(adress).Result);
 }