public Bot GetOrCreate(BotInfo info) { var bot = this.FirstOrDefault(item => item.Info.Name == info.Name && item.Info.Version == info.Version); if (bot != null) { bot.Info = info.SetIsActive(false); return(bot); } var previous = this .Where(item => item.Info.Name == info.Name && item.Info.Version < info.Version) .OrderByDescending(item => item.Info.Version).FirstOrDefault(); bot = new Bot() { Info = info, }; if (previous != null) { bot.Rating = previous.Rating; } this.Add(bot); return(bot); }