Example #1
0
        public async Task <ExistRequest> GetExistRescue(long rescue)
        {
            var result = new ExistRequest();

            var sign = await GetOauth();

            if (sign.IsAuthenticated)
            {
                var url = string.Format("api/v3/existrequest?Token={0}&CodRequest={1}", _config.GetToken(), rescue.ToString());
                _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", sign.AccessToken);

                var response = await _client.GetAsync(url);

                if (response.IsSuccessStatusCode)
                {
                    var information = response.Content.ReadAsStringAsync().Result;
                    result = JsonConvert.DeserializeObject <ExistRequest>(information);
                }
                else
                {
                    var information = response.Content.ReadAsStringAsync().Result;
                    result.Message = response.RequestMessage.ToString();
                }
            }

            return(result);
        }
Example #2
0
        public JObject Exist(JObject json)
        {
            logger.Info("Exist post request received - searching for user in the database");
            ExistRequest user    = json.ToObject <ExistRequest>();
            User         current = db.GetCollection <User>().Find(Query.EQ("username", user.username)).FirstOrDefault();
            JObject      tmp     = new JObject();

            if (current != null)
            {
                logger.Info("User has been found in the database.");
                tmp.Add("exist", true);
                return(tmp);
            }
            else
            {
                logger.Info("User does not exist in the database.");
                tmp.Add("exist", false);
                return(tmp);
            }
        }