public async Task<IHttpActionResult> PutListaSpesa(long id, ListaSpesa listaSpesa)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != listaSpesa.IdListaSpesa)
            {
                return BadRequest();
            }
            
            db.Entry(listaSpesa).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ListaSpesaExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
        public async Task<IHttpActionResult> PostListaSpesa(ListaSpesa listaSpesa)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.ListaSpesa.Add(listaSpesa);
            await db.SaveChangesAsync();

            return CreatedAtRoute("DefaultApi", new { id = listaSpesa.IdListaSpesa }, listaSpesa);
        }
      public async Task<IHttpActionResult> SendListaSpesa(ListaSpesa listaSpesa)
      {
          ListaSpesaDto dto = await db.ListaSpesa
                                      .Include(x => x.UtentiListaSpesa)
                                      .Include(x => x.VociListaSpesa)
                                      .Where(x => x.IdListaSpesa == listaSpesa.IdListaSpesa)
                                      .Select(x => new ListaSpesaDto()
                                      {
                                          Nome = x.Nome,
                                          Voci = x.VociListaSpesa.Select(y => new VoceDto()
                                                                  {
                                                                      Name = y.Voce.Name,
                                                                      Comprata = y.Comprata
                                                                  }).ToList(),
                                          Utenti = x.UtentiListaSpesa.Select(y => y.Utente).ToList()
                                      })
                                      .FirstOrDefaultAsync();
 
          if(await EmailService.SendAsync(dto))
              return Ok();
          return InternalServerError();
      }