public static RestRequest CreateCountriesRequest(int page, int countriesPerPage, RequestFormat format)
        {
            var restReq = new RestRequest(HttpMethod.Get);

            restReq.AddQueryParameter("format", format.ToString());
            restReq.AddQueryParameter("page", page);
            restReq.AddQueryParameter("per_page", countriesPerPage);

            return restReq;
        }
Example #2
0
        public async Task<UsuarioModel> ValidarUsuario(UsuarioModel usuario)
        {
            var request = new RestRequest("Usuario");
            request.Method = Method.GET;
            request.AddQueryParameter("Username", usuario.Username);
            request.AddQueryParameter("Password", usuario.Password);

            var response = await client.Execute<UsuarioModel>(request);
            if (response.IsSuccess) return response.Data;
            return null;
        }
Example #3
0
        public async Task<UsuarioModel> ValidarUsuario(UsuarioModel usuario)
        {
            var request = new RestRequest("Usuario");
            //Al request se le pueden añadir Headers, y al client se le pueden añadir credentials
            request.Method = Method.GET;
            request.AddQueryParameter("login", usuario.login);
            request.AddQueryParameter("password", usuario.password);

            var reponse = await client.Execute<UsuarioModel>(request);
            if (reponse.IsSuccess) return reponse.Data;
            return null;
        }
Example #4
0
        public async Task<List<ContactoModel>> GetContactos(bool actuales, int id)
        {
            var request = new RestRequest("Contactos");

            request.Method = Method.GET;
            request.AddQueryParameter("id", id);
            request.AddQueryParameter("amigos", actuales);

            var reponse = await client.Execute<List<ContactoModel>>(request);
            if (reponse.IsSuccess) return reponse.Data;
            return null;
        }
        public async Task<UsuarioModel> ValidarUsuario(UsuarioModel model)
        {
            var request = new RestRequest("Usuario") { Method = Method.GET };
            request.AddQueryParameter("username", model.Username);
            request.AddQueryParameter("password", model.Password);

            // la api devuelve error 404 si no existe, y restsharp peta
            var response = await _client.Execute<UsuarioModel>(request);
            if (response.IsSuccess)
                return response.Data;

            return null;

        }
        private async Task<List<ActivitySummary>> GetAthleteActivities(DateTime before, DateTime after, int page, int itemsPerPage)
        {
            var request = new RestRequest("/api/v3/athlete/activities");
            if (before != DateTime.MinValue)
                request.AddQueryParameter("before", before.GetSecondsSinceUnixEpoch());
            if (after != DateTime.MinValue)
                request.AddQueryParameter("after", after.GetSecondsSinceUnixEpoch());
            if (page != 0)
                request.AddParameter("page", page);
            if (itemsPerPage != 0)
                request.AddParameter("per_page", itemsPerPage);
            var response = await _client.RestClient.Execute<List<ActivitySummary>>(request);

            return response.Data;
        }
        public Task<Component> GetComponentAsync(string roomId, string deviceId)
        {
            var request = new RestRequest("component") {Method = HttpMethod.Get};
            request.AddQueryParameter("roomId", roomId);
            request.AddQueryParameter("deviceId", deviceId);

            var task = _client.Execute<Component>(request).ContinueWith(t =>
            {
                if (t.Result.StatusCode == HttpStatusCode.OK)
                {
                    return t.Result.Data;
                }
                throw new Exception("There is something wrong here");
            });
            return task;
        }
Example #8
0
        public async Task<bool> UsuarioNuevo(string username)
        {
            var request = new RestRequest("Usuario");
            request.Method = Method.GET;
            request.AddQueryParameter("Username", username);

            var response = await client.Execute<bool>(request);
            if (response.IsSuccess) return response.Data;
            return false;
        }
Example #9
0
 public async Task<UsuarioModel> GetUsuariosId(int id)
 {
     var request = new RestRequest("Usuario");
     request.Method = Method.GET;
     request.AddQueryParameter("id", id);
     var response = await client.Execute<UsuarioModel>(request);
     if (response.IsSuccess)
         return response.Data;
     return null;
 }
        public async Task<bool> CheckUsuario(string email)
        {
            var request = new RestRequest("Usuario") { Method = Method.GET };
            request.AddQueryParameter("email", email);

            var response = await _client.Execute<bool>(request);

            if (response.IsSuccess)
                return response.Data;
            return false;
        }
Example #11
0
        public async Task<ICollection<TareaModel>> GetByGrupo(int id)
        {
            var request = new RestRequest("Tarea");
            request.Method = Method.GET;
            request.AddQueryParameter("idGrupo", id);

            var response = await client.Execute<ICollection<TareaModel>>(request);
            if (response.IsSuccess)
                return response.Data;
            return null;
        }
        public async Task<ICollection<TareaModel>> GetTareas(int grupoId)
        {
            var request = new RestRequest("Tarea") { Method = Method.GET };
            request.AddQueryParameter("grupoId", grupoId);

            var response = await _client.Execute<ICollection<TareaModel>>(request);
            if (response.IsSuccess)
                return response.Data;

            return null;
        }
        public async Task<ICollection<MensajeModel>> GetMensajesEnviados(int userId)
        {
            var request = new RestRequest("Mensaje") { Method = Method.GET };
            request.AddQueryParameter("emisorId", userId);

            var response = await _client.Execute<List<MensajeModel>>(request);
            if (response.IsSuccess)
                return response.Data;

            return null;
        }
        public async Task<ICollection<GrupoModel>> GetGrupos(int userId)
        {
            var request = new RestRequest("Grupo") { Method = Method.GET };
            request.AddQueryParameter("userId", userId);

            var response = await _client.Execute<ICollection<GrupoModel>>(request);
            if (response.IsSuccess)
                return response.Data;
            return null;
        }
Example #15
0
 public async Task DeleteAmigo(int idUsuario, int idAmigo)
 {
     var request = new RestRequest("Contacto");
     request.Method = Method.DELETE;
     request.AddQueryParameter("idUsuario", idUsuario);
     request.AddQueryParameter("idAmigo", idAmigo);
     var response = await client.Execute<ContactoModel>(request);
 }
Example #16
0
 public async Task<ICollection<UsuarioModel>> GetContactos(int id)
 {
     var request = new RestRequest("Contacto");
     request.Method = Method.GET;
     request.AddQueryParameter("id", id);
     var response = await client.Execute<ICollection<UsuarioModel>>(request);
     if (response.IsSuccess)
         return response.Data;
     return null;
 }
Example #17
0
 public async Task<List<MensajeModel>> GetEnviados(int idOrigen)
 {
     var request=new RestRequest("Mensaje");
     request.Method=Method.GET;
     request.AddQueryParameter("IdOrigen", idOrigen);
     var response = await client.Execute<List<MensajeModel>>(request);
     if (response.IsSuccess)
         return response.Data;
     return null;
 }
Example #18
0
 public async Task<List<MensajeModel>> GetMensajes(int userId)
 {
     var request = new RestRequest("Mensaje");
     request.Method = Method.GET;
     request.AddQueryParameter("IdDestino", userId);
     var response = await client.Execute<List<MensajeModel>>(request);
     if (response.IsSuccess)
         return response.Data;
     return null;
 }
Example #19
0
 public async Task DeleteMensaje(int id)
 {
     var request = new RestRequest("Mensaje");
     request.Method = Method.DELETE;
     request.AddQueryParameter("id", id);
     var response = await client.Execute<MensajeModel>(request);
 }
        public async Task<bool> UpdateTarea(TareaModel model)
        {
            var request = new RestRequest("Tarea") { Method = Method.PUT };
            request.AddQueryParameter("id", model.Id);
            request.AddJsonBody(model);

            try
            {
                var response = await _client.Execute(request);
                if (response.IsSuccess)
                    return true;
            }
            catch (Exception ex)
            {

                var r = ex.Message;
            }

            return false;
        }
        public async Task<bool> DeleteTarea(int id)
        {
            var request = new RestRequest("Tarea") { Method = Method.DELETE };
            request.AddQueryParameter("id", id);

            var response = await _client.Execute(request);
            if (response.IsSuccess)
                return true;

            return false;
        }
        public async Task<ICollection<MensajeModel>> GetMensajesRecibidos(int userId)
        {
            var request = new RestRequest("Mensaje") { Method = Method.GET };
            request.AddQueryParameter("receptorId", userId);

            // la api devuelve error 404 si no existe, y restsharp peta
            var response = await _client.Execute<List<MensajeModel>>(request);
            if (response.IsSuccess)
                return response.Data;

            return null;
        }
        public async Task<List<MensajeModel>> GetMensaje(int id)
        {
            var request = new RestRequest("Mensaje")
            {
                Method = Method.GET
            };

            request.AddQueryParameter("id", id);
            
            var response = await client.Execute<List<MensajeModel>>(request);
            if (response.IsSuccess)
            {
                return response.Data;
            }
            return null;
        }
        public async Task DeleteContacto(int userId, int amigoId)
        {
            var request = new RestRequest("Contacto") { Method = Method.DELETE };
            request.AddQueryParameter("idUsuario", userId);
            request.AddQueryParameter("idAmigo", amigoId);

            await _client.Execute(request);
        }
        public async Task DeleteMensaje(int id)
        {
            var request = new RestRequest("Mensaje") { Method = Method.DELETE };
            request.AddQueryParameter("id", id);

            await _client.Execute(request);
        }
        public async Task<MensajeModel> GetMensaje(int id)
        {
            var request = new RestRequest("Mensaje") { Method = Method.GET };
            request.AddQueryParameter("id", id);

            // la api devuelve error 404 si no existe, y restsharp peta
            var response = await _client.Execute<MensajeModel>(request);
            if (response.IsSuccess)
                return response.Data;

            return null;
        }