public async Task <IActionResult> GetByCategoryId(string id, [FromHeader] string queryBy)
        {
            _logger.LogDebug("Returning the specified category: " + id);
            var tenantDomain   = _currentTenant.DomainId;
            var categoryResult = await _repo.All <Category>().Include(c => c.Jobs)
                                 .SingleAsync(ApiQueryExpression.GenerateCategoryPredicate(id, queryBy, tenantDomain));

            var categoryModel = JobAssistantMapper.Map <CategoryModel>(categoryResult);

            return(Ok(categoryModel));
        }
示例#2
0
        public async Task <IActionResult> GetByApplicationId(string id, [FromHeader] string queryBy)
        {
            var tenantDomain      = _currentTenant.DomainId;
            var applicationResult = await _repo.All <Application>().Include(a => a.ToolRelationships)
                                    .Include(a => a.AccessoryRelationships)
                                    .FirstOrDefaultAsync(ApiQueryExpression.GenerateApplicationPredicate(id, queryBy, tenantDomain));

            var applicationModel = JobAssistantMapper.Map <ApplicationModel>(applicationResult);

            return(Ok(applicationModel));
        }
示例#3
0
        public async Task <IActionResult> GetAccessoryById(string id, [FromHeader] string queryBy)
        {
            _logger.LogDebug("Looking up accessory data for the specified id: " + id);
            var tenantDomain    = _currentTenant.DomainId;
            var accessoryResult = await _repo.All <Accessory>()
                                  .SingleOrDefaultAsync(ApiQueryExpression.GenerateAccessoryPredicate(id, queryBy, tenantDomain));

            var accessoryModel = JobAssistantMapper.Map <AccessoryModel>(accessoryResult);

            _logger.LogDebug("Returning accessory data for the specified accessory: " + accessoryModel.Name);
            return(Ok(accessoryModel));
        }
示例#4
0
        public async Task <IActionResult> GetToolById(string id, [FromHeader] string queryBy)
        {
            _logger.LogDebug("Looking up tool data associated to the specified id: " + id);
            var tenantDomain = _currentTenant.DomainId;
            var toolResult   = await _repo.All <Tool>()
                               .SingleOrDefaultAsync(ApiQueryExpression.GenerateToolPredicate(id, queryBy, tenantDomain));

            _logger.LogDebug("Tool data " + toolResult.Name + " (ToolId = " + toolResult.ToolId + ")");
            var toolModel = JobAssistantMapper.Map <ToolModel>(toolResult);

            _logger.LogDebug("Returning tool data for the specified tool: " + toolModel.Name);
            return(Ok(toolModel));
        }
        public async Task <IActionResult> GetByMaterialId(string id, [FromHeader] string queryBy)
        {
            _logger.LogDebug("Returning material data for the specified id: " + id);
            var tenantDomain = _currentTenant.DomainId;
            // TODO: Validate that the tenant/domain exists and based on the security context,
            // TODO (continued): that the API caller should have access to it!
            var materialResult = await _repo.All <Material>().Include(m => m.Applications)
                                 .FirstOrDefaultAsync(ApiQueryExpression.GenerateMaterialPredicate(id, queryBy, tenantDomain));

            var materialModel = JobAssistantMapper.Map <MaterialModel>(materialResult);

            return(Ok(materialModel));
        }
        public async Task <IActionResult> GetByJobId(string id, [FromHeader] string queryBy)
        {
            var tenantDomain = _currentTenant.DomainId;

            _logger.LogDebug($"Looking up job data for the specified: {id} (using data tenant: {tenantDomain})");
            var jobResult = await _repo.All <Job>().FirstOrDefaultAsync(ApiQueryExpression.GenerateJobPredicate(id, queryBy, tenantDomain));

            var jobModel = JobAssistantMapper.Map <JobModel>(jobResult);

            _logger.LogDebug("Returning job data for the specified job: " + jobModel.Name);

            var helper         = new JobLinksBuilder();
            var modelWithLinks = helper.ToModelWithLinks(jobModel, HttpContext.Request);

            return(Ok(modelWithLinks));
        }