public async Task SendLike(StreamWriter writer, string[] msg, string replyTo, char direction, IServiceProvider services) { string phrase = msg[0].Split(":")[1]; string[] input = new string[2]; if (direction == '+') { phrase = phrase.Split("+")[0]; input[0] = phrase; input[1] = "1"; } else { phrase = phrase.Split("-")[0]; input[0] = phrase; input[1] = "-1"; } if (Like.CreateLike(input, replyTo) is Like like) { using var scope = services.CreateScope(); LikeRepository repository = scope.ServiceProvider.GetRequiredService <LikeRepository>(); Like newLike = await repository.UpsertLike(like); writer.WriteLine(newLike?.GetSendMessage()); writer.Flush(); } }