Example #1
0
        /// Algo
        ///1. Document Information.
        ///2. List of Resource Information
        ///     2.a. String Information
        ///         2.a.i. Removal Information
        public List <DocumentInformation> GetAllEnglishStrings(EnglishStringPayload payload)
        {
            m_payload = payload;
            List <DocumentInformation> documentInformationList = new List <DocumentInformation>();

            try
            {
                m_removalStringList = m_functionService.Udf_GetRemovedStrings(payload.BranchId.Value, payload.ModifiedDateUTC);
                foreach (var resourceId in payload.ResourceIds)
                {
                    ///DocumentContent
                    DocumentInformation documentInformation = new DocumentInformation
                    {
                        DocumentContent = m_functionService.GetDocumentContent(resourceId),
                        VoScriptIds     = m_dbContext.TVoscript
                                          .Where(x => x.BranchId == payload.BranchId)
                                          .Where(x => x.ParentResourceId == resourceId)
                                          .Where(x => x.IsActive)
                                          .Select(x => x.VoscriptId)
                                          .ToList()
                    };

                    var resourceVersionIdList = new List <int> {
                        documentInformation.DocumentContent.ResourceVersionId
                    };

                    foreach (var resourceVersionId in resourceVersionIdList)
                    {
                        ParentResource parentResource = new ParentResource
                        {
                            LocalizationResourceId        = resourceId,       //parentResourceAttributes.ResourceID,
                            LocalizationResourceVersionId = resourceVersionId //resourceVersionId,
                        };
                        documentInformation.ResourceInformation.AddRange(GetTextInformation(resourceVersionId, parentResource));
                    }
                    documentInformationList.Add(documentInformation);
                }
            }
            catch (Exception ex)
            {
                m_loggerService.LogError(ex.Message);
            }

            return(documentInformationList);
        }
        public EnglishStringsDto GetAllEnglishString(EnglishStringPayload payload, int pageNumber, int pageSize)
        {
            EnglishStringsDto result = new EnglishStringsDto();

            try
            {
                var resourceInformationList = m_locAPIService.GetAllEnglishStrings(payload);
                var totalCount = resourceInformationList.Count;
                var totalPages = m_paginationService.CalculateTotalPage(totalCount, pageSize);
                result.PrevPage        = m_paginationService.GetPreviousPageLink(pageNumber);
                result.NextPage        = m_paginationService.GetNextPageLink(pageNumber, totalPages);
                result.ContextDocument = resourceInformationList.Skip(pageSize * pageNumber)
                                         .Take(pageSize).ToList();
            }
            catch (Exception ex)
            {
                m_loggerService.LogError(ex.Message);
            }
            return(result);
        }
Example #3
0
        public IActionResult EnglishStream()
        {
            EnglishStringPayload payload = new EnglishStringPayload();
            int pageNumber = 0;
            int pageSize   = 1;

            if (ModelState.IsValid)
            {
                var result = m_locAPIService.GetAllEnglishString(payload, pageNumber, pageSize);
                return(Ok(result));
            }
            else
            {
                string messages = string.Join(",", ModelState.Values
                                              .SelectMany(x => x.Errors)
                                              .Select(x => x.ErrorMessage));
                m_logger.LogError("Error in Payload: {0}", messages);
                return(BadRequest());
            }
        }