public async Task GetEventosAsync(GetEventos peticion) { Eventos = new List <GetEventosResponse>(); try { var solicitud = await EGuardianAPI.PostAsync(Constants.Endpoint_Evento_GetEventosByEmpresa + peticion.parametros, null); solicitud.EnsureSuccessStatusCode(); string respuesta = await solicitud.Content.ReadAsStringAsync(); Eventos = JsonConvert.DeserializeObject <List <GetEventosResponse> >(respuesta); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("ERROR: " + e.Message); } var eventos = App.Database.GetEventos(Convert.ToInt32(Settings.session_idUsuario)).ToList(); if (eventos.Count != 0) { App.Database.DeleteAllEventos(); } try { foreach (var evento in Eventos) { App.Database.InsertEvento( new eventos { estado = evento.status, idUsuario = Convert.ToInt32(Settings.session_idUsuario), asunto = string.IsNullOrEmpty(evento.nombre)?string.Empty: evento.nombre.ToUpper(), fechaFin = evento.fechaFin, fechaInicio = evento.fechaInicio, duracion = evento.duracion, idUserCreator = evento.idUserCreator, idEvento = evento.idEvento } ); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }
public Task GetEventosAsync(GetEventos peticion) { return(ServicioWeb.GetEventosAsync(peticion)); }