예제 #1
0
        public async Task <IActionResult> AddMarker(Marker marker)
        {
            var list    = _slaMarkerService.GetSlaMarkers().ToList();
            var polygon = PolygonCheckerService.IsInPolygon(list, marker.latitude, marker.longitude);

            if (polygon == true)
            {
                // SignalR event
                var signalNotification = new NotificationDto
                {
                    Title       = "Too many markers!",
                    Description = "You can not create a marker here",
                    Type        = "Notify",
                    CreatedAt   = DateTime.UtcNow.ToString()
                };
                await _hubNotificationContext.Clients.All.SendAsync("GetNewNotification", signalNotification);

                return(Conflict());
            }

            var markerItem = await _repository.AddAsync(marker);

            // SignalR event
            await _hubContext.Clients.All.SendAsync("GetNewMarker", markerItem);

            return(Ok(markerItem));
        }
 public ActionResult <IEnumerable <SlaMarker> > GetAllSlaMarkers()
 {
     return(Ok(_slaMarkerService.GetSlaMarkers()));
 }