Beispiel #1
0
        public IHttpActionResult GetAgent(int id)
        {
            agents = agentStore.getDictionary();
            foreach (KeyValuePair <int, Agent> entry in agents)
            {
                if (entry.Key == id)
                {
                    return(Content(HttpStatusCode.OK, entry.Value));
                }
            }

            return(Content(HttpStatusCode.NoContent, "Not Found"));
        }
Beispiel #2
0
        public IHttpActionResult Getmin(int OrderID)
        {
            agents = agentstore.getDictionary();
            orders = orderstore.getDictionary();
            Orders  orderfound = new Orders();
            Boolean b          = false;

            foreach (KeyValuePair <int, Orders> entry in orders)
            {
                if (entry.Key == OrderID)
                {
                    orderfound = entry.Value;
                    b          = true;
                }
            }
            if (b == false)
            {
                return(Content(HttpStatusCode.NoContent, "OrderId not found"));
            }
            Agent nearestagent = new Agent();
            int   min          = 1000;
            int   dis;

            foreach (KeyValuePair <int, Agent> entry in agents)
            {
                dis = getDistance(orderfound.Lat, orderfound.Long, entry.Value.Lat, entry.Value.Long);
                if (dis < min && entry.Value.status == true)
                {
                    nearestagent = entry.Value;
                }
            }

            return(Content(HttpStatusCode.OK, nearestagent));
        }