예제 #1
0
        public HttpResponseMessage GetPublic([FromUri] int organizationId, [FromUri] PagingModel <ItSystem> paging, [FromUri] string q)
        {
            try
            {
                var systemQuery = _systemService.GetAvailableSystems(organizationId, q);

                var query = Page(systemQuery, paging)
                            .AsEnumerable()
                            .Select(system => system.MapToNamedEntityWithEnabledStatusDTO())
                            .ToList();

                return(Ok(query));
            }
            catch (Exception e)
            {
                return(LogError(e));
            }
        }
예제 #2
0
        public IHttpActionResult GetItSystems(
            Guid?rightsHolderUuid = null,
            Guid?businessTypeUuid = null,
            string kleNumber      = null,
            Guid?kleUuid          = null,
            int?numberOfUsers     = null,
            [FromUri] StandardPaginationQuery paginationQuery = null)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var refinements = new List <IDomainQuery <ItSystem> >();

            if (rightsHolderUuid.HasValue)
            {
                refinements.Add(new QueryByRightsHolder(rightsHolderUuid.Value));
            }

            if (businessTypeUuid.HasValue)
            {
                refinements.Add(new QueryByBusinessType(businessTypeUuid.Value));
            }

            if (kleNumber != null || kleUuid.HasValue)
            {
                refinements.Add(new QueryByTaskRef(kleNumber, kleUuid));
            }

            if (numberOfUsers.HasValue)
            {
                refinements.Add(new QueryByNumberOfUsages(numberOfUsers.Value));
            }

            return(_itSystemService.GetAvailableSystems(refinements.ToArray())
                   .OrderBy(x => x.Id)
                   .Page(paginationQuery)
                   .ToList()
                   .Select(ToDTO)
                   .Transform(Ok));
        }