public QueriesOutput CreateQuery(QueriesInput input)
        {
            var output = new QueriesOutput();

            output = _queriesRepository.CreateQuery(input);
            return(output);
        }
Esempio n. 2
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);
        }