示例#1
0
        public PortfolioVM GetPortfolio()
        {
            try
            {
                //Get the data of postions static object
                var portfolio = this.mandateService.GetPortfolio();

                var filePath = _configuration["FilePath"];
                //Get funds of Mandate data from file
                string fileName       = Path.GetFullPath(filePath);
                var    fundOfMandates = this.mandateService.GetFundOfMandatesFromXML(fileName);

                _logger.LogInformation("Received funds of Mandate data from XML.", fileName.Count());

                //Map response and get calculated mandates
                var position           = DomainModelMapper.MapPosition(portfolio);
                var calculatedPosition = this.mandateService.CalculateMandates(position, fundOfMandates);

                _logger.LogInformation("Mandate Calculations completed.", position);

                //Map Response from API
                var response = ResponseBuilder.MapPortfolio(calculatedPosition);

                return(response);
            }
            catch (FileNotFoundException ex)
            {
                _logger.LogError("File does not exist", ex.FileName);
                throw ex;
            }
            catch (ArgumentNullException ex)
            {
                _logger.LogError("Null", ex.ParamName);
                throw ex;
            }
            catch (Exception ex)
            {
                _logger.LogError("There is some error.", ex.Message);
                throw ex;
            }
        }