예제 #1
0
 public IEnumerable <Heroi> Get(string nome = null, int?id = null)
 {
     return(ListaHerois.Where(x =>
                              (id == null || id == x.Id) &&
                              (nome == null || x.Nome == nome)
                              ));
 }
예제 #2
0
 public IHttpActionResult Post(Heroi heroi)
 {
     if (heroi == null)
     {
         return(BadRequest());
     }
     else
     {
         lock (objetoLock)
         {
             heroi.Id = ++IdContador;
             ListaHerois.Add(heroi);
         }
         return(Ok(heroi));
     }
 }