Beispiel #1
0
        public IActionResult GetActiveCallsList(int linkId)
        {
            var link = _departmentLinksService.GetLinkById(linkId);

            List <CallListJson> callsJson = new List <CallListJson>();

            if (link.DepartmentId != DepartmentId && link.LinkedDepartmentId != DepartmentId)
            {
                Unauthorized();
            }

            if (link.LinkEnabled && link.DepartmentShareCalls)
            {
                var calls      = _callsService.GetActiveCallsByDepartment(link.DepartmentId).OrderByDescending(x => x.LoggedOn);
                var department = _departmentsService.GetDepartmentById(link.DepartmentId, false);

                foreach (var call in calls)
                {
                    var callJson = new CallListJson();
                    callJson.CallId     = call.CallId;
                    callJson.Number     = call.Number;
                    callJson.Name       = call.Name;
                    callJson.State      = _callsService.CallStateToString((CallStates)call.State);
                    callJson.StateColor = _callsService.CallStateToColor((CallStates)call.State);
                    callJson.Timestamp  = call.LoggedOn.TimeConverterToString(department);
                    callJson.Priority   = _callsService.CallPriorityToString(call.Priority, link.DepartmentId);
                    callJson.Color      = _callsService.CallPriorityToColor(call.Priority, link.DepartmentId);

                    if (ClaimsAuthorizationHelper.IsUserDepartmentAdmin() || call.ReportingUserId == UserId)
                    {
                        callJson.CanDeleteCall = true;
                    }
                    else
                    {
                        callJson.CanDeleteCall = false;
                    }

                    callsJson.Add(callJson);
                }
            }

            return(Json(callsJson));
        }