public TypesOutput GetTypeById(TypesInput input)
        {
            var output = new TypesOutput();

            output = _typesRepository.GetTypeById(input);
            return(output);
        }
        public QueriesOutput GetQueryWithTypeByQueryId(QueriesInput input)
        {
            var output = new QueriesOutput();

            output = _queriesRepository.GetQueryById(input);
            if (output.QueriesModel != null)
            {
                var typeId = output.QueriesModel.TypeId;
                if (typeId.HasValue && typeId > 0)
                {
                    var typeInput = new TypesInput();
                    typeInput.Id = typeId.Value;
                    var type = _typesRepository.GetTypeById(typeInput);
                    if (type.TypesModel != null)
                    {
                        var typeDto = new TypesDto();
                        typeDto = _mapper.Map <TypesDto>(type.TypesModel);
                        output.QueriesModel.TypeModel = typeDto;
                    }
                }
            }
            return(output);
        }
示例#3
0
        public TemplatesOutput GetTemplateWithTypeByTemplateId(TemplatesInput input)
        {
            var output = new TemplatesOutput();

            output = _templatesRepository.GetTemplateById(input);
            if (output.TemplatesModel != null)
            {
                var typeId = output.TemplatesModel.TypeId;
                if (typeId.HasValue && typeId > 0)
                {
                    var typeInput = new TypesInput();
                    typeInput.Id = typeId.Value;
                    var type = _typesRepository.GetTypeById(typeInput);
                    if (type.TypesModel != null)
                    {
                        var typeDto = new TypesDto();
                        typeDto = _mapper.Map <TypesDto>(type.TypesModel);
                        output.TemplatesModel.TypeModel = typeDto;
                    }
                }
            }
            return(output);
        }
示例#4
0
        private JobsOutput Navigator(JobsOutput input)
        {
            var output = input;

            if (output.JobsListModel != null && output.JobsListModel.Count > 0)
            {
                //templates
                var templateIdList = output.JobsListModel.Select(x => x.TemplateId);
                var templates      = _templatesRepository.GetAll();

                var filteredTemplates = new List <Templates>();
                if (templateIdList.Count() > 0 && templates.Count > 0)
                {
                    filteredTemplates = templates.Where(x => templateIdList.Contains(x.Id)).ToList();
                }
                //templates

                //queries
                var queryIdList = output.JobsListModel.Select(x => x.QueryId);
                var queries     = _queriesRepository.GetAll();

                var filteredQueries = new List <Queries>();
                if (queryIdList.Count() > 0 && queries.Count > 0)
                {
                    filteredQueries = queries.Where(x => queryIdList.Contains(x.Id)).ToList();
                }
                //queries

                //types
                var typeIdList = output.JobsListModel.Select(x => x.TypeId);
                var types      = _typesRepository.GetAll();

                var filteredTypes = new List <Types>();
                if (typeIdList.Count() > 0 && types.Count > 0)
                {
                    filteredTypes = types.Where(x => typeIdList.Contains(x.Id)).ToList();
                }
                //types

                foreach (var job in output.JobsListModel)
                {
                    var selectedTemplate = filteredTemplates.Where(x => x.Id == job.TemplateId).SingleOrDefault();
                    job.TemplatesModel = selectedTemplate != null?_mapper.Map <TemplatesDto>(selectedTemplate) : null;

                    var selectedQuery = filteredQueries.Where(x => x.Id == job.QueryId).SingleOrDefault();
                    job.QueriesModel = selectedQuery != null?_mapper.Map <QueriesDto>(selectedQuery) : null;

                    var selectedType = filteredTypes.Where(x => x.Id == job.TypeId).SingleOrDefault();
                    job.TypesModel = selectedType != null?_mapper.Map <TypesDto>(selectedType) : null;
                }
            }
            else
            {
                //template
                var templateInput = new TemplatesInput();
                output.JobsModel = new JobsDto();
                var templateId = output.JobsModel.TemplateId;
                templateInput.Id = templateId.Value;
                var template = _templatesRepository.GetTemplateById(templateInput);
                output.JobsModel.TemplatesModel = _mapper.Map <TemplatesDto>(template.TemplatesModel);
                //template

                //query
                var queryInput = new QueriesInput();
                var queryId    = output.JobsModel.QueryId;
                queryInput.Id = queryId.Value;
                var query = _queriesRepository.GetQueryById(queryInput);
                output.JobsModel.QueriesModel = _mapper.Map <QueriesDto>(query.QueriesModel);
                //query

                //type
                var typeInput = new TypesInput();
                var typeId    = output.JobsModel.QueryId;
                typeInput.Id = typeId.Value;
                var type = _typesRepository.GetTypeById(typeInput);
                output.JobsModel.TypesModel = _mapper.Map <TypesDto>(type.TypesModel);
                //type
            }

            return(output);
        }
示例#5
0
        public InstantsOutput CreateInstant(InstantsInput input)
        {
            var output = new InstantsOutput();

            output.InstantsModel = new InstantsDto();

            if (input.TemplateId == null)
            {
                var template = _templatesRepository.CreateTemplate(_mapper.Map <TemplatesInput>(input.TemplatesModel));
                if (template != null)
                {
                    output.InstantsModel.TemplatesModel = template.TemplatesModel;
                    input.TemplateId = output.InstantsModel.TemplateId = template.TemplatesModel.Id;
                }
            }
            else
            {
                var templateInput = new TemplatesInput();
                templateInput.Id = input.TemplateId.Value;
                var template = _templatesRepository.GetTemplateById(templateInput);
                if (template != null)
                {
                    output.InstantsModel.TemplatesModel = template.TemplatesModel;
                }
            }

            if (input.QueryId == null)
            {
                var query = _queriesRepository.CreateQuery(_mapper.Map <QueriesInput>(input.QueriesModel));
                if (query != null)
                {
                    output.InstantsModel.QueriesModel = query.QueriesModel;
                    input.QueryId = output.InstantsModel.QueryId = query.QueriesModel.Id;
                }
            }
            else
            {
                var queryInput = new QueriesInput();
                queryInput.Id = input.QueryId.Value;
                var query = _queriesRepository.GetQueryById(queryInput);
                if (query != null)
                {
                    output.InstantsModel.QueriesModel = query.QueriesModel;
                }
            }

            var typeInput = new TypesInput();

            typeInput.Id = input.TypeId.Value;
            var type = _typesRepository.GetTypeById(typeInput);

            if (type.TypesModel != null)
            {
                output.InstantsModel.TypesModel = type.TypesModel;
                input.TypeId = type.TypesModel.Id;
            }

            var instant = Create(_mapper.Map <Instants>(input));

            if (instant != null)
            {
                output.InstantsModel = _mapper.Map <InstantsDto>(instant);
            }

            return(output);
        }