public async Task <DataResult <IEnumerable <TicketInformation> > > GetTickets() { var client = _httpClientFactory.CreateClient(); HttpResponseMessage response = await client.GetAsync( $"{_ticketServiceConfiguration.Endpoint}/GetTickets"); if (response.IsSuccessStatusCode) { string result = await response.Content.ReadAsStringAsync(); var options = new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; var data = JsonSerializer.Deserialize <IEnumerable <TicketInformation> >(result, options); return(DataResult <IEnumerable <TicketInformation> > .Success(data)); } else { // Log error return(DataResult <IEnumerable <TicketInformation> > .Failure($"Error: {response.ReasonPhrase}")); } }
public DataResult Delete(int id) { try { notebookManager.dataSource.Delete(id); } catch (DataSourceException e) { return(DataResult.Failure(e.Message)); } return(DataResult.Success()); }
public DataResult Update(Notebook notebook) { try { notebookManager.dataSource.Update(notebook); } catch (DataSourceException e) { return(DataResult.Failure(e.Message)); } return(DataResult.Success()); }
public DataResult Authenticate(string username, string password) { try { Web.Models.Token response = ChronicyWebApi.Shared.Authenticate(username, password); if (response.HasError) { return(DataResult.Failure(response.ErrorMessage)); } } catch (WebApiException e) { InformationDispatcher.Default.Dispatch(e, DebugLogContext.Current); return(DataResult.Failure("Could not authenticate")); } return(DataResult.Success()); }