public ActionResult <string> GetTopSecretSplitAll()
        {
            string resVal = "";

            try
            {
                Task <AllSatellitesData> allSatellitesData     = _dbTopSecretSplitController.GetListOfValidatedSatellitesData();
                TopSecretResponseData    topSecretResponseData = _ImperialSnifferMainClass.GetImperialShipInformation(allSatellitesData.Result);

                resVal = JsonConvert.SerializeObject(topSecretResponseData);
                return(resVal);
            }
            catch (Exception ex)
            {
                //fileLogger.Log(ex.Message);
                return(NotFound());
            }
        }
Example #2
0
        public ActionResult <string> PostTopSecret(dynamic data)
        {
            try
            {
                //Request and Response data definitions
                string                requestData            = data.ToString();
                string                responseData           = "";
                AllSatellitesData     satellitesInformation  = JsonConvert.DeserializeObject <AllSatellitesData>(requestData);
                TopSecretResponseData topSecretResponsetData = imperialSniffer.GetImperialShipInformation(satellitesInformation);

                responseData = JsonConvert.SerializeObject(topSecretResponsetData);
                return(responseData);
            }
            catch (Exception ex)
            {
                //TODO: Log exception Message.
                return(NotFound());
            }
        }
        /// <summary>
        /// This main method resolve the required conditions of the topsecret level 2 exercice.
        /// Ask for the methods created in exercice level 1 GetPosition and GetMessage
        /// </summary>
        /// <param name="allSatelites"></param>
        /// <returns></returns>
        public TopSecretResponseData GetImperialShipInformation(AllSatellitesData allSatelites)
        {
            //use the TopSecret exercice required response Data from the response.
            TopSecretResponseData topSecretResponseData = new TopSecretResponseData();

            //Get Location
            ShipLocator   shipLocator  = new ShipLocator();
            XYCoordinates shipLocation = shipLocator.GetLocation(allSatelites);

            topSecretResponseData.position.x = shipLocation.GetCoordinateX();
            topSecretResponseData.position.y = shipLocation.GetCoordinateY();

            ///Get Message
            MessageAssembler      messageAssembler       = new MessageAssembler();
            List <List <string> > messagesFromSatellites = messageAssembler.GetMessagesListFromSatelliteData(allSatelites);

            topSecretResponseData.message = messageAssembler.GetMessage(messagesFromSatellites);

            return(topSecretResponseData);
        }