dp
continuous-integration/drone/push Build is failing Details

derniererbranche
etudiant 2 years ago
parent a6b22e027a
commit 9d75faaeef

@ -11,7 +11,6 @@
<PropertyGroup Condition=" '$(RunConfiguration)' == 'https' " /> <PropertyGroup Condition=" '$(RunConfiguration)' == 'https' " />
<PropertyGroup Condition=" '$(RunConfiguration)' == 'http' " /> <PropertyGroup Condition=" '$(RunConfiguration)' == 'http' " />
<PropertyGroup Condition=" '$(RunConfiguration)' == 'RestFull' " />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\net6.0\BowlingApi.xml</DocumentationFile> <DocumentationFile>bin\Debug\net6.0\BowlingApi.xml</DocumentationFile>

@ -121,6 +121,67 @@ namespace BowlingApi.Controllers
} }
[HttpGet("{page}/{pageSize}")]
[ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
[ProducesResponseType(typeof(string), StatusCodes.Status404NotFound)]
[ProducesResponseType(typeof(IEnumerable<PartieDTO>), StatusCodes.Status200OK)]
public async Task<IActionResult> Get(int page = 1, int pageSize = 10)
{
try
{
var result = await _partieService.GetAll();
if (result == null)
{
return NotFound();
}
var data = result.Skip((page - 1) * pageSize).Take(pageSize);
Response.Headers.Add("X-Pagination", Newtonsoft.Json.JsonConvert.SerializeObject(new
{
totalCount = result.Count(),
pageSize = pageSize,
currentPage = page,
totalPages = (int)Math.Ceiling(result.Count() / (double)pageSize)
}));
return Ok(data);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
throw;
}
}
/// <summary>
/// Supprimer une partie par son id
/// DELETE: api/parti/5
/// </summary>
/// <param name="id"></param>
/// <response code="200">Retourne la partie supprimé</response>
/// <response code="404">Si la partie n'existe pas</response>
/// <response code="500">Si une erreur est survenue</response>
[HttpDelete("{id}")]
[ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
[ProducesResponseType(typeof(string), StatusCodes.Status404NotFound)]
[ProducesResponseType(typeof(bool), StatusCodes.Status200OK)]
[MapToApiVersion("2")]
public async Task<ActionResult<bool>> Delete(long id)
{
try
{
var parti = _partieService.Delete(id);
if (parti.Result == false)
{
return NotFound();
}
return Ok(parti);
}
catch (Exception e)
{
StatusCode(StatusCodes.Status500InternalServerError, e.Message);
throw;
}
}
/// <summary> /// <summary>
/// Modification partie /// Modification partie
/// PUT: api/parti/5 /// PUT: api/parti/5

Binary file not shown.

@ -8,6 +8,7 @@ namespace BowlingService.Interfaces
{ {
public Task<PartieDTO> Add(PartieDTO _partie); public Task<PartieDTO> Add(PartieDTO _partie);
public Task<bool> Delete(PartieDTO _partie); public Task<bool> Delete(PartieDTO _partie);
public Task<bool> Delete(long id);
public Task<bool> Update(PartieDTO _partie); public Task<bool> Update(PartieDTO _partie);
public Task<IEnumerable<PartieDTO>> GetAll(); public Task<IEnumerable<PartieDTO>> GetAll();
public Task<IEnumerable<PartieEntity>> GetAllWithDate(DateTime date); public Task<IEnumerable<PartieEntity>> GetAllWithDate(DateTime date);

@ -152,6 +152,27 @@ public async Task<PartieDTO> Add(PartieDTO _partie)
return result; return result;
} }
public async Task<bool> Delete(long _partiid)
{
var result = false;
try
{
result = await _IpartieRepository.Delete(_partiid);
if (result)
_logger.LogInformation("A parti was deleted : {player}", _partiid);
else
_logger.LogWarning("A parti not found : {player}", _partiid);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error while deleting player : {player}", _partiid);
throw;
}
return result;
}
} }
} }

Loading…
Cancel
Save