public async Task <Friend> Update(Friend friend) { var checkFriend = await Get(friend.Id); if (checkFriend == null) { return(null); } var local = _dbContext.Set <Friend>().Local.FirstOrDefault(l => l.Id.Equals(friend.Id)); if (local != null) { _dbContext.Entry(local).State = EntityState.Detached; } _dbContext.Entry(checkFriend).State = EntityState.Modified; checkFriend.Name = friend.Name; if (friend.UserId != null) { checkFriend.UserId = friend.UserId; } _dbContext.Friends.Update(checkFriend); await SaveAsync(); return(checkFriend); }
public async Task <Game> Update(Game game) { var checkGame = await Get(game.Id); if (checkGame == null) { return(null); } var local = _dbContext.Set <Game>().Local.FirstOrDefault(l => l.Id.Equals(game.Id)); if (local != null) { _dbContext.Entry(local).State = EntityState.Detached; } _dbContext.Entry(checkGame).State = EntityState.Modified; checkGame.Name = game.Name; _dbContext.Games.Update(checkGame); await SaveAsync(); return(game); }