public IHttpActionResult PutUser(int id, UserDTO userDTO) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != userDTO.UserId) { return BadRequest(); } try { userRepo.EditUser(userDTO); } catch (DbUpdateConcurrencyException) { if (userRepo.GetUserID(id) == null) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostUser(UserDTO userDTO) { if (!ModelState.IsValid) { return BadRequest(ModelState); } userRepo.Create(userDTO); return CreatedAtRoute("DefaultApi", new { id = userDTO.UserId }, userDTO); }
public User userDTOToUser(UserDTO userDTO) { return Mapper.Map<User>(userDTO); }
public void EditUser(UserDTO userDTO) { db.Entry(mapper.userDTOToUser(userDTO)).State = EntityState.Modified; db.SaveChanges(); }
public void Create(UserDTO userDTO) { db.Users.Add(mapper.userDTOToUser(userDTO)); db.SaveChanges(); }