public IHttpActionResult PutUsers(int id, Users users) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != users.Id) { return BadRequest(); } db.Entry(users).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UsersExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostUsers(Users users) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Users.Add(users); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = users.Id }, users); }
public UserViewModel(Users user) { UserId = user.Id; Username = user.Username; FirstName = user.FirstName; lastName = user.LastName; Email = user.Email; UserGames = new List<UsersGamesViewModel>(); foreach (var game in user.UsersGames) { UserGames.Add(new UsersGamesViewModel(game)); } }