private void MergeIntoAllCollection(AgentRM agent) { List <AgentRM> allAgents = new List <AgentRM>(); if (Exists("all")) { allAgents = Get <List <AgentRM> >("all"); } //If the district already exists in the ALL collection, remove that entry if (allAgents.Any(x => x.AgentID == agent.AgentID)) { allAgents.Remove(allAgents.First(x => x.AgentID == agent.AgentID)); } //Add the modified district to the ALL collection allAgents.Add(agent); Save("all", allAgents); }
public async Task Handle(AgentCreatedEvent message) { AgentRM agent = _mapper.Map <AgentRM>(message); _agentRepo.Save(agent); }
public void Save(AgentRM agent) { Save(agent.AgentID, agent); MergeIntoAllCollection(agent); }