public static async Task <List <RUsuarioEvento> > GetRUsuarioEventoAsync(RUsuarioEvento rUsuarioEvento) { try { string url = "http://www.accessfun.somee.com/api/RUsuarioEventos?id=" + rUsuarioEvento.Id + "&email=" + rUsuarioEvento.Email; var response = await client.GetStringAsync(url); var eventos = JsonConvert.DeserializeObject <List <RUsuarioEvento> > (response); return(eventos); } catch (Exception ex) { throw ex; } }
public static async Task DeixarParticipacaoEventoAsync(RUsuarioEvento rUsuarioEvento) { try { string url = "http://www.accessfun.somee.com/api/RUsuarioEventos?id=" + rUsuarioEvento.Id + "&email=" + rUsuarioEvento.Email; var uri = new Uri(string.Format(url, rUsuarioEvento.Email)); HttpResponseMessage response = null; response = await client.DeleteAsync(uri); if (!response.IsSuccessStatusCode) { throw new Exception("Erro ao deletar evento"); } } catch (Exception ex) { throw ex; } }
public static async Task ParticiparEventoAsync(RUsuarioEvento r) { try { string url = "http://www.accessfun.somee.com/api/RUsuarioEventos/{0}"; var uri = new Uri(string.Format(url, r.Email)); var data = JsonConvert.SerializeObject(r); var content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = null; response = await client.PostAsync(uri, content); if (!response.IsSuccessStatusCode) { throw new Exception("Erro ao incluir usuario"); } } catch (Exception ex) { throw ex; } }