Example #1
0
        public IActionResult AddArtifact([FromBody] ArtifactDTO artifact)
        {
            if (artifact.Latitude < -90 || artifact.Latitude > 90 || artifact.Longitude < -180 || artifact.Longitude > 180)
            {
                return(BadRequest("Invalid coordinates"));
            }
            var id = artifactRepository.AddArtifact(artifact);

            if (id.HasValue)
            {
                var art = artifactRepository.GetById(id.Value);
                wsContext.Clients.All.SendAsync("ArtifactSet", id.Value, art.Longitude, art.Latitude);
                return(Json(id.Value));
            }
            return(BadRequest());
        }