public async Task <ActionResult> GetUsers() { var user = await _context.Users.FirstOrDefaultAsync(); if (user == null) { return(NotFound()); } UserWithApi userWithApi = new UserWithApi() { UserId = user.UserId, UserAvatar = user.UserAvatar, NickName = user.NickName, Introduction = user.Introduction, Motto = user.Motto }; return(Ok(userWithApi)); }
public async Task <IActionResult> PutUser(int id, UserWithApi userWithApi) { if (id != userWithApi.UserId) { return(BadRequest()); } if (UserExists(id)) { var user = await _context.Users.FirstOrDefaultAsync(u => u.UserId == id); user.UserAvatar = userWithApi.UserAvatar; user.NickName = userWithApi.NickName; user.Introduction = userWithApi.Introduction; user.Motto = userWithApi.Motto; await _context.SaveChangesAsync(); return(Ok()); } return(NotFound()); }