// GET api/rules/abmob1 public MsgHandlers Get(string from) { Agent agent1 = new Agent("*****@*****.**", 7); List<Agent> agents = new List<Agent> { agent1 }; MsgHandlers listOfAgents = new MsgHandlers(agents); return listOfAgents; throw new HttpResponseException(HttpStatusCode.NotFound); }
// GET api/rules/abmob1 public MsgHandlers Get(string from) { Agent agent1 = new Agent("*****@*****.**", 7); Agent agent2 = new Agent("*****@*****.**", 7); List<Agent> agents = new List<Agent> { agent1 , agent2}; MsgHandlers listOfAgents = new MsgHandlers(agents); return listOfAgents; throw new HttpResponseException(HttpStatusCode.NotFound); }
/// <summary> /// Gets most important agents by ordering them with the amount of houses each has for sale /// </summary> /// <param name="housesForSale">a list of houses for sale</param> /// <param name="count">count of agents to return (x in top x)</param> /// <returns>top x of agents together with the amount of houses for sale they have</returns> public IEnumerable<AgentImportance> GetImportantAgents(IEnumerable<HouseForSale> housesForSale, int count) { var agentsGrouped = (from h in housesForSale group h by h.MakelaarId into g orderby g.Count() descending select g).Take(count); var result = new List<AgentImportance>(); foreach (var item in agentsGrouped) { var agent = new Agent(); agent.Id = item.Key; agent.Name = housesForSale.Where(h => h.MakelaarId == agent.Id).Select(h => h.MakelaarNaam).First(); var agentWithImportance = new AgentImportance(agent, item.Count()); result.Add(agentWithImportance); } return result; }
public AgentImportance(Agent agent, int amountOfHousesForSale) { Agent = agent; AmountOfHousesForSale = amountOfHousesForSale; }