/// <summary> /// Creates an element /// </summary> /// <param name="menu"></param> /// <returns></returns> public async Task <Menu> Create(Menu menu) { var response = await _httpClient.PostAsJsonAsync(MenuApiRouteConfig.Create(), menu); if (!response.IsSuccessStatusCode) { _logger.LogError(LogMessages.Error.UnknownProblem(string.Empty)); return(null); } return(await response.Content.ReadAsAsync <Menu>()); }
/// <summary> /// Deletes an element /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <bool> Delete(int id) { if (id <= 0) { _logger.LogError(LogMessages.Error.InvalidInput()); return(false); } var response = await _httpClient.DeleteAsync(MenuApiRouteConfig.Delete(id)); return(response.IsSuccessStatusCode); }
/// <summary> /// Finds an element in a remote Http repository /// </summary> /// <param name="id">Menu id</param> /// <returns></returns> public async Task <Menu> Find(int id) { var response = await _httpClient.GetAsync(MenuApiRouteConfig.Find(id)); if (!response.IsSuccessStatusCode) { _logger.LogError(LogMessages.Error.UnknownProblem(id.ToString())); return(null); } return(await response.Content.ReadAsAsync <Menu>()); }