Ejemplo n.º 1
0
        public async Task <IActionResult> GetContractAdviceTemplatesByTags(string company, [FromBody, Required] IEnumerable <TagDto> request)
        {
            List <TemplatesBestMatchDto> templateList = new List <TemplatesBestMatchDto>();

            IEnumerable <EntitiesBestMatchDto> result = await _tagService.ListContractAdviceTemplatesByTagsAsync(company, request);

            var documentTemplates = await _physicalDocumentGenerationService.GetTemplates(PhysicalDocumentType.ContractAdvice, company, true);

            foreach (var item in result.ToList())
            {
                var template = documentTemplates.FirstOrDefault(x => x.Id == item.EntityExternalId);
                if (template == null)
                {
                    continue;
                }

                templateList.Add(new TemplatesBestMatchDto()
                {
                    EntityId           = item.EntityId,
                    PhysicalDocumentId = item.EntityExternalId,
                    BestMatch          = item.BestMatch,
                    Name        = template.Name,
                    Description = template.Description
                });
            }

            return(this.Ok(templateList));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <IEnumerable <TemplateWithTagsDto> > > GetContractAdviceTemplatesWithTagsByCompanyAsync(string company)
        {
            var templatesResult = new List <TemplateWithTagsDto>();

            var templates = await physicalDocumentGenerationService.GetTemplates(PhysicalDocumentType.ContractAdvice, company);

            if (templates.Any())
            {
                var templatesIds = templates.Select(t => t.Id).ToList();
                var entityTags   = await tagServiceForContractAdvice.GetContractAdviceTemplateWithTagsByIdsAsync(company, templatesIds);

                foreach (var templateId in templatesIds)
                {
                    var entities = entityTags.Where(e => e.EntityExternalId == templateId).Distinct();

                    foreach (var entity in entities)
                    {
                        templatesResult.Add(
                            new TemplateWithTagsDto
                        {
                            EntityId         = entity.EntityId,
                            EntityExternalId = entity.EntityExternalId,
                            Name             = templates.FirstOrDefault(t => t.Id == templateId).Name,
                            Tags             = entity.Tags,
                            IsDeactivated    = entity.IsDeactivated
                        });
                    }
                }
            }

            return(Ok(templatesResult));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <CollectionViewModel <PhysicalDocumentTemplateDto> > > GetTemplates(
            string company,
            [Range(1, long.MaxValue)] long documentTypeId,
            string module)
        {
            var documentTemplates = await _physicalDocumentGenerationService.GetTemplates((PhysicalDocumentType)documentTypeId, company, true, module);

            var templates = documentTemplates
                            .Select(i => new PhysicalDocumentTemplateDto
            {
                DocumentTemplateId = i.Id,
                Name             = i.Name,
                Path             = i.Path,
                Description      = i.Description,
                CreatedDateTime  = i.CreatedDateTime,
                CreatedBy        = i.CreatedBy,
                ModifiedDateTime = i.ModifiedDateTime,
                ModifiedBy       = i.ModifiedBy
            }).ToList();

            var response = new CollectionViewModel <PhysicalDocumentTemplateDto>(templates);

            return(Ok(response));
        }