public IActionResult TopSecretSplit(string name, SatelliteForm satellite) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } string cookieData = GetCookie("message"); List <Satellite> data = new List <Satellite>(); if (!string.IsNullOrEmpty(cookieData)) { data = JsonSerializer.Deserialize <List <Satellite> >(cookieData); } List <Satellite> tempData = new List <Satellite>(); Satellite currentSatelite = new Satellite() { Name = name, Distance = satellite.Distance, Message = satellite.Message }; tempData.Add(currentSatelite); if (!Communications.ValidateSateliteInfo(tempData)) { return(BadRequest("The information is incomplete!!")); } var FinalList = data.Union(tempData).ToList(); if (FinalList.Count <= Communications.GetSatellites().Count()) { SetCookie("message", JsonSerializer.Serialize(FinalList), 0.5); return(BadRequest("Need more information")); } else { Point finalPosition = Communications.GetLocation(FinalList); if (finalPosition == null) { return(BadRequest("Ops Somethig go wrong!!")); } var reponse = new { position = new { x = finalPosition.PositionX, y = finalPosition.PositionY }, message = Communications.GetMessage(FinalList) }; DeleteCookie("message"); return(Ok(reponse)); } }