Exemplo n.º 1
0
        public async Task <ActionResult <List <DepartmentLinkResult> > > GetActiveDepartmentLinks()
        {
            if (!await _limitsService.CanDepartmentUseLinksAsync(DepartmentId))
            {
                return(new List <DepartmentLinkResult>());
            }

            var linkResults = new List <DepartmentLinkResult>();
            var links       = await _departmentLinksService.GetAllLinksForDepartmentAsync(DepartmentId);

            foreach (var link in links)
            {
                if (link.LinkedDepartmentId == DepartmentId && link.LinkEnabled)
                {
                    var department = await _departmentsService.GetDepartmentByIdAsync(link.DepartmentId);

                    var result = new DepartmentLinkResult();
                    result.LinkId         = link.DepartmentLinkId;
                    result.DepartmentName = department.Name;
                    result.Color          = link.DepartmentColor;
                    result.ShareCalls     = link.DepartmentShareCalls;
                    result.ShareOrders    = link.DepartmentShareOrders;
                    result.SharePersonnel = link.DepartmentSharePersonnel;
                    result.ShareUnits     = link.DepartmentShareUnits;

                    linkResults.Add(result);
                }
            }

            return(linkResults);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Index()
        {
            var model = new LinksIndexView();

            model.DepartmentId = DepartmentId;
            model.Links        = await _departmentLinksService.GetAllLinksForDepartmentAsync(DepartmentId);

            model.CanCreateLinks = await _limitsService.CanDepartmentUseLinksAsync(DepartmentId);

            var department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId);

            model.Code = department.LinkCode;

            return(View(model));
        }