public async Task<IHttpActionResult> PutUtente(long id, Utente utente)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != utente.IdUtente)
            {
                return BadRequest();
            }

            db.Entry(utente).State = EntityState.Modified;

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

            return StatusCode(HttpStatusCode.NoContent);
        }
        public async Task<IHttpActionResult> PostUtente(Utente utente)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Utente.Add(utente);
            await db.SaveChangesAsync();

            return CreatedAtRoute("DefaultApi", new { id = utente.IdUtente }, utente);
        }
Example #3
0
 public UtenteDto(Utente u)
 {
     this.Email = u.Email;
     this.IdUtente = u.IdUtente;
     this.Username = u.Username;
 }