public async Task SubscribeToDepartmentLink(int linkId) { var link = await _departmentLinksService.GetLinkByIdAsync(linkId); if (link != null && link.LinkEnabled) { await Groups.AddToGroupAsync(Context.ConnectionId, link.DepartmentId.ToString()); } }
public async Task <IActionResult> EnableLink(int linkId, CancellationToken cancellationToken) { var link = await _departmentLinksService.GetLinkByIdAsync(linkId); if (link.LinkedDepartmentId != DepartmentId) { Unauthorized(); } link.LinkEnabled = true; link.LinkAccepted = DateTime.UtcNow; await _departmentLinksService.SaveAsync(link, cancellationToken); return(RedirectToAction("Index")); }
public async Task <ActionResult <List <LinkedCallResult> > > GetActiveCallsForLink(int linkId) { var result = new List <LinkedCallResult>(); var link = await _departmentLinksService.GetLinkByIdAsync(linkId); if (link.DepartmentId != DepartmentId && link.LinkedDepartmentId != DepartmentId) { return(new List <LinkedCallResult>()); } var calls = (await _callsService.GetActiveCallsByDepartmentAsync(link.DepartmentId)).OrderByDescending(x => x.LoggedOn); var department = await _departmentsService.GetDepartmentByIdAsync(link.DepartmentId, false); foreach (var c in calls) { var call = new LinkedCallResult(); call.Cid = c.CallId; call.Pri = c.Priority; call.Ctl = c.IsCritical; call.Nme = StringHelpers.SanitizeHtmlInString(c.Name); if (!String.IsNullOrWhiteSpace(c.NatureOfCall)) { call.Noc = StringHelpers.SanitizeHtmlInString(c.NatureOfCall); } call.Map = c.MapPage; if (!String.IsNullOrWhiteSpace(c.Notes)) { call.Not = StringHelpers.SanitizeHtmlInString(c.Notes); } if (c.CallNotes != null) { call.Nts = c.CallNotes.Count(); } else { call.Nts = 0; } if (c.Attachments != null) { call.Aud = c.Attachments.Count(x => x.CallAttachmentType == (int)CallAttachmentTypes.DispatchAudio); call.Img = c.Attachments.Count(x => x.CallAttachmentType == (int)CallAttachmentTypes.Image); call.Fls = c.Attachments.Count(x => x.CallAttachmentType == (int)CallAttachmentTypes.File); } else { call.Aud = 0; call.Img = 0; call.Fls = 0; } if (String.IsNullOrWhiteSpace(c.Address) && !String.IsNullOrWhiteSpace(c.GeoLocationData)) { var geo = c.GeoLocationData.Split(char.Parse(",")); if (geo.Length == 2) { call.Add = await _geoLocationProvider.GetAddressFromLatLong(double.Parse(geo[0]), double.Parse(geo[1])); } } else { call.Add = c.Address; } call.Geo = c.GeoLocationData; call.Lon = c.LoggedOn.TimeConverter(department); call.Ste = c.State; call.Num = c.Number; call.Priority = c.ToCallPriorityDisplayText(); call.PriorityCss = c.ToCallPriorityCss(); call.State = c.ToCallStateDisplayText(); call.StateCss = c.ToCallStateCss(); result.Add(call); } return(Ok(result)); }