diff --git a/Controllers/FormationsApi.cs b/Controllers/FormationsApi.cs index 561eb2e..07303c1 100644 --- a/Controllers/FormationsApi.cs +++ b/Controllers/FormationsApi.cs @@ -11,16 +11,12 @@ using System; using System.Collections.Generic; using Microsoft.AspNetCore.Mvc; using Swashbuckle.AspNetCore.Annotations; -using Swashbuckle.AspNetCore.SwaggerGen; using Newtonsoft.Json; using System.ComponentModel.DataAnnotations; using IO.Swagger.Attributes; -using IO.Swagger.Security; -using Microsoft.AspNetCore.Authorization; using IO.Swagger.DTO; using EPAServeur.IServices; -using System.Reflection.Metadata.Ecma335; -using System.Runtime.InteropServices.WindowsRuntime; +using System.Linq; namespace IO.Swagger.Controllers { @@ -55,14 +51,6 @@ namespace IO.Swagger.Controllers FormationDTO nouvelleFormation = formationService.AddFormation(body); return Created("", nouvelleFormation); - //if (body.Id != null && body.Id > 0) - //{ - // return StatusCode(201, body); - //} - //else - //{ - // return NotFound(); - //} } /// @@ -89,6 +77,7 @@ namespace IO.Swagger.Controllers }; return NotFound(erreur); } + return NoContent(); } @@ -117,7 +106,7 @@ namespace IO.Swagger.Controllers { //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... IEnumerable formations = formationService.GetFormationAnnulees(asc, numPage, parPAge, idAgence, texte, tri); - if (formations == null) + if (formations.Count() == 0) { ErreurDTO erreur = new ErreurDTO() { @@ -186,7 +175,7 @@ namespace IO.Swagger.Controllers { //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... IEnumerable formations = formationService.GetFormationRealisee(asc, numPage, parPAge, idAgence, texte, tri); - if (formations == null) + if (formations.Count() == 0) { ErreurDTO erreur = new ErreurDTO() { @@ -224,7 +213,7 @@ namespace IO.Swagger.Controllers { //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... IEnumerable formations = formationService.GetFormations(asc, numPage, parPAge, idAgence, texte, tri); - if (formations == null) + if (formations.Count() == 0) { ErreurDTO erreur = new ErreurDTO() { @@ -254,7 +243,7 @@ namespace IO.Swagger.Controllers { //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... IEnumerable modeFormations = formationService.GetModesFormation(); - if (modeFormations == null) + if (modeFormations.Count() == 0) { ErreurDTO erreur = new ErreurDTO() { @@ -284,7 +273,7 @@ namespace IO.Swagger.Controllers { //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... IEnumerable origineFormations = formationService.GetOriginesFormation(); - if (origineFormations == null) + if (origineFormations.Count() == 0) { ErreurDTO erreur = new ErreurDTO() { @@ -322,7 +311,7 @@ namespace IO.Swagger.Controllers { //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... IEnumerable formations = formationService.GetProchainesFormation(asc, numPage, parPAge, idAgence, texte, tri); - if (formations == null) + if (formations.Count() == 0) { ErreurDTO erreur = new ErreurDTO() { @@ -352,7 +341,7 @@ namespace IO.Swagger.Controllers { //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... IEnumerable statutFormations = formationService.GetStatutsFormation(); - if (statutFormations == null) + if (statutFormations.Count() == 0) { ErreurDTO erreur = new ErreurDTO() { @@ -382,7 +371,7 @@ namespace IO.Swagger.Controllers { //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... IEnumerable typeFormations = formationService.GetTypesFormation(); - if (typeFormations == null) + if (typeFormations.Count() == 0) { ErreurDTO erreur = new ErreurDTO() {