/// <summary> /// Crea un artículo en la base de datos /// </summary> /// <param name="Artículo"></param> /// <returns></returns> public async Task <ArtículoDto> AdicionarAsync(ArtículoDto Artículo) { HttpResponseMessage response; var elUri = $"{_MyStringUri}/Adicionar"; Artículo.EstadoId = EstadoEnum.Activo; string json = JsonSerializer.Serialize(Artículo); try { response = await _consumirAPIService.POSTRequestAsync(elUri, json); } catch (Exception ex) { _logger.LogError(ex.Message); return(null); } return(JsonSerializer.Deserialize <ArtículoDto>(response.Content.ReadAsStringAsync().Result, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true })); ; }
/// <summary> /// Eliminar un artículo por Id /// </summary> /// <param name="artículoId"></param> /// <returns></returns> public async Task <bool> EliminarAsync(ArtículoDto Artículo) { HttpResponseMessage response; var elUri = $"{_MyStringUri}/Eliminar"; string json = JsonSerializer.Serialize(Artículo); try { response = await _consumirAPIService.DELETERequestAsync(elUri, json); } catch (Exception ex) { Console.WriteLine(ex.Message); _logger.LogError(ex.Message); return(false); } return(true);; }
protected override void OnInitialized() { ElArtículo = new ArtículoDto(); }