示例#1
0
        public IHttpActionResult AddAgent(Agent agentadd)
        {
            agents = agentStore.getDictionary();
            Boolean b = true;

            foreach (KeyValuePair <int, Agent> entry in agents)
            {
                if (entry.Key == agentadd.ID)
                {
                    b = false;
                    break;
                }
            }

            if (b == true)
            {
                agents.Add(agentadd.ID, agentadd);
                return(Content(HttpStatusCode.Created, agents));
            }
            else
            {
                return(Content(HttpStatusCode.BadRequest, "agent already exists"));
            }
            agentStore.StoreDictionary(agents);
        }