Exemple #1
0
        public SearchResult <PumpAccessRightModel> SearchPumpAccessRight(PumpAccessRightCriteria criteria)
        {
            var userGroups = unitOfWork.UserGroupRepository.GetAll().Select(t => new { Id = t.Id, Name = t.Name, IsGroup = true });
            var users      = unitOfWork.UserRepository.GetAll().Select(t => new { Id = t.Id, Name = t.FirstName + " " + t.LastName, IsGroup = false });
            var principals = userGroups.Union(users);
            var query      = pumpRepository.GetAccessRights(criteria.PumpId)
                             .Join(principals, a => a.Principal, p => p.Id, (a, p) => new PumpAccessRightModel()
            {
                Access             = a.Access,
                CanLock            = a.CanLock,
                CanUnlock          = a.CanUnlock,
                Principal          = a.Principal,
                CanUpdateParameter = a.CanUpdateParameter,
                PrincipalName      = p.IsGroup ? "[" + p.Name + "]" : p.Name,
                PumpId             = a.PumpId
            });

            var result = new SearchResult <PumpAccessRightModel>();

            result.ItemCount  = query.Count();
            query             = query.Sort(criteria.Sorting, new Sorting("PrincipalName", SortDirection.Ascending));
            query             = query.Page(criteria.Paging);
            result.ResultData = query.ToList();
            return(result);
        }
        public IActionResult SearchPumpAccessRight(PumpAccessRightCriteria criteria)
        {
            var result = pumpService.SearchPumpAccessRight(criteria);

            return(Ok(new SuccessResult(result)));
        }