Example #1
0
        // получить избраные помещения пользователя
        public async Task <List <FavoriteRoom> > Get(int id)
        {
            HttpClient client = WebData.GetClient();
            string     result = await client.GetStringAsync(Url + "/" + id);

            return(JsonConvert.DeserializeObject <List <FavoriteRoom> >(result));
        }
Example #2
0
        // получаем все публичные заметки о здании
        public async Task <List <Note> > GetPublic(int buildingid) // переделать
        {
            HttpClient client = WebData.GetClient();
            string     result = await client.GetStringAsync(Url + "/" + buildingid);

            return(JsonConvert.DeserializeObject <List <Note> >(result));
        }
Example #3
0
        // получаем все этажи выбраного здания
        public async Task <List <Floor> > GetFloors(int buildingid)
        {
            HttpClient client = WebData.GetClient();
            string     result = await client.GetStringAsync(Url + buildingid);

            return(JsonConvert.DeserializeObject <List <Floor> >(result));
        }
Example #4
0
        // получаем список доступных к загрузке зданий
        public async Task <List <Building> > GetBuildings()
        {
            HttpClient client = WebData.GetClient();
            string     result = await client.GetStringAsync(Url);

            return(JsonConvert.DeserializeObject <List <Building> >(result));
        }
Example #5
0
        // удалить избранное помещение
        public async Task <bool> Delete(int id)
        {
            HttpClient client   = WebData.GetClient();
            var        response = await client.DeleteAsync(Url + "/" + id);

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

            return(false);
        }
Example #6
0
        // удалить заметку
        public async Task <Note> Delete(int id)
        {
            HttpClient client   = WebData.GetClient();
            var        response = await client.DeleteAsync(Url + "/" + id);

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

            return(JsonConvert.DeserializeObject <Note>(
                       await response.Content.ReadAsStringAsync()));
        }
Example #7
0
        // сохранить новое избраное помезение
        public async Task <FavoriteRoom> Add(FavoriteRoom room)
        {
            HttpClient client   = WebData.GetClient();
            var        response = await client.PostAsync(Url,
                                                         new StringContent(
                                                             JsonConvert.SerializeObject(room),
                                                             Encoding.UTF8, "application/json"));

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

            return(JsonConvert.DeserializeObject <FavoriteRoom>(
                       await response.Content.ReadAsStringAsync()));
        }
Example #8
0
        // сохранить новую заметку
        public async Task <Note> Add(Note note)
        {
            HttpClient client   = WebData.GetClient();
            var        response = await client.PostAsync(Url + "/PostAddNote",
                                                         new StringContent(
                                                             JsonConvert.SerializeObject(note),
                                                             Encoding.UTF8, "application/json"));

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

            return(JsonConvert.DeserializeObject <Note>(
                       await response.Content.ReadAsStringAsync()));
        }
Example #9
0
        // получить все заметки выбраного клиента
        public async Task <List <Note> > GetClient(int id)
        {
            Dictionary <string, int> req = new Dictionary <string, int>();

            req.Add("id", id);

            HttpClient client   = WebData.GetClient();
            var        response = await client.PostAsync(Url + "/PostClientNote",
                                                         new StringContent(
                                                             JsonConvert.SerializeObject(req),
                                                             Encoding.UTF8, "application/json"));

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

            return(JsonConvert.DeserializeObject <List <Note> >(
                       await response.Content.ReadAsStringAsync()));
        }
Example #10
0
        /// <summary>
        /// Запрос системе на регистрацию нового пользователя
        /// </summary>
        /// <param name="name">Имя</param>
        /// <param name="login">Логин </param>
        /// <param name="pass">Пароль</param>
        /// <returns>Id,Login,Name пользователя в случае верных данных, иначе NULL</returns>
        public async Task <Dictionary <string, string> > Register(string name, string login, string pass)
        {
            Dictionary <string, string> user = new Dictionary <string, string>();

            user.Add("Name", name);
            user.Add("Login", login);
            user.Add("Pass", pass);

            HttpClient          client   = WebData.GetClient();
            HttpResponseMessage response = await client.PostAsync(Url + "/PostRegister",
                                                                  new StringContent(
                                                                      JsonConvert.SerializeObject(user),
                                                                      Encoding.UTF8, "application/json"));

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

            return(JsonConvert.DeserializeObject <Dictionary <string, string> >(
                       await response.Content.ReadAsStringAsync()));
        }