Exemple #1
0
        public InstantsOutput GetInstantByIdFilter(InstantsInput input)
        {
            var output = new InstantsOutput();

            if (input.Id > 0)
            {
                var instant = GetWithFilter(x => x.Id == input.Id);
                if (instant != null)
                {
                    output.InstantsModel = _mapper.Map <InstantsDto>(instant);
                }
                else
                {
                    var instantList = GetAll();
                    if (input.TemplateId != null && input.TemplateId > 0)
                    {
                        instantList = instantList.Where(x => x.TemplateId == input.TemplateId).ToList();
                    }
                    if (input.QueryId != null && input.QueryId > 0)
                    {
                        instantList = instantList.Where(x => x.QueryId == input.QueryId).ToList();
                    }
                    if (input.TypeId != null && input.TypeId > 0)
                    {
                        instantList = instantList.Where(x => x.TypeId == input.TypeId).ToList();
                    }
                    output.InstantsListModel = _mapper.Map <List <InstantsDto> >(instantList);
                }
            }
            return(output);
        }
        public InstantsOutput UpdateInstant(InstantsInput input)
        {
            var output = new InstantsOutput();

            output = _instantService.UpdateInstant(input);
            return(output);
        }
        public InstantsOutput GetInstantByIdFilter(InstantsInput input)
        {
            var output = new InstantsOutput();

            output = _instantService.GetInstantByIdFilter(input);
            return(output);
        }
        public InstantsOutput GetInstantByIdFilterWithTypeTemplateQuery(InstantsInput input)
        {
            var output = new InstantsOutput();

            output = _instantService.GetInstantByIdFilterWithTypeTemplateQuery(input);
            return(output);
        }
Exemple #5
0
        public InstantsOutput UpdateInstant(InstantsInput input)
        {
            var output = new InstantsOutput();

            output = _instantsRepository.UpdateInstant(input);
            return(output);
        }
Exemple #6
0
        public InstantsOutput GetInstantByIdFilter(InstantsInput input)
        {
            var output = new InstantsOutput();

            output = _instantsRepository.GetInstantByIdFilter(input);
            return(output);
        }
Exemple #7
0
        public InstantsOutput GetInstantByIdFilterWithTypeTemplateQuery(InstantsInput input)
        {
            var output = new InstantsOutput();

            output = FilteredInstants(input);
            output = Navigator(output);
            return(output);
        }
Exemple #8
0
        private InstantsOutput FilteredInstants(InstantsInput input)
        {
            var output   = new InstantsOutput();
            var instants = _instantsRepository.GetAllInstants();

            instants = GetInstantByIdFilter(input);
            output   = Navigator(instants);
            return(output);
        }
Exemple #9
0
        public InstantsOutput UpdateInstant(InstantsInput input)
        {
            var output = new InstantsOutput();

            Update(_mapper.Map <Instants>(input));
            var instant = GetWithFilter(x => x.Id == input.Id);

            output.InstantsModel = _mapper.Map <InstantsDto>(instant);
            return(output);
        }
Exemple #10
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);
        }
Exemple #11
0
 public bool DeleteInstant(InstantsInput input)
 {
     return(Delete(_mapper.Map <Instants>(input)));
 }
 public bool DeleteInstant(InstantsInput input)
 {
     return(_instantService.DeleteInstant(input));
 }
Exemple #13
0
 public bool DeleteInstant(InstantsInput input)
 {
     return(_instantsRepository.DeleteInstant(input));
 }