public async Task <int> Edit(EditSubFundInputModel model)
        {
            SubFundPostDto dto = AutoMapperConfig.MapperInstance.Map <SubFundPostDto>(model);

            SubFundForeignKeysDto dtoForeignKey = AutoMapperConfig.MapperInstance.Map <SubFundForeignKeysDto>(model);

            await this.SetForeignKeys(dto, dtoForeignKey);

            SqlCommand command = this.AssignBaseParameters(dto, SqlProcedureDictionary.EditSubFund);

            // Assign particular parameters
            command.Parameters.AddRange(new[]
            {
                new SqlParameter("@sf_id", SqlDbType.Int)
                {
                    Value = dto.Id
                },
                new SqlParameter("@comment", SqlDbType.NVarChar)
                {
                    Value = dto.CommentArea
                },
                new SqlParameter("@comment_title", SqlDbType.NVarChar)
                {
                    Value = dto.CommentTitle
                },
                new SqlParameter("@sf_shortSubFundName ", SqlDbType.NVarChar)
                {
                    Value = dto.SubFundName
                },
            });

            await this.sqlManager.ExecuteProcedure(command);

            return(dto.Id);
        }
        private async Task SetForeignKeys(SubFundPostDto dto, SubFundForeignKeysDto dtoForeignKey)
        {
            dto.Status = await this.repositorySelectList.ByIdST(dtoForeignKey.Status);

            dto.CesrClass = await this.repositorySelectList.ByIdCC(dtoForeignKey.CesrClass);

            dto.GeographicalFocus = await this.repositorySelectList.ByIdGF(dtoForeignKey.GeographicalFocus);

            dto.GlobalExposure = await this.repositorySelectList.ByIdGE(dtoForeignKey.GlobalExposure);

            dto.NavFrequency = await this.repositorySelectList.ByIdNF(dtoForeignKey.NavFrequency);

            dto.ValuationDate = await this.repositorySelectList.ByIdVD(dtoForeignKey.ValuationDate);

            dto.CalculationDate = await this.repositorySelectList.ByIdCD(dtoForeignKey.CalculationDate);

            dto.DerivMarket = await this.repositorySelectList.ByIdDM(dtoForeignKey.DerivMarket);

            dto.DerivPurpose = await this.repositorySelectList.ByIdDP(dtoForeignKey.DerivPurpose);

            dto.PrincipalAssetClass = await this.repositorySelectList.ByIdPAC(dtoForeignKey.PrincipalAssetClass);

            dto.TypeOfMarket = await this.repositorySelectList.ByIdTM(dtoForeignKey.TypeOfMarket);

            dto.PrincipalInvestmentStrategy = await this.repositorySelectList.ByIdPIS(dtoForeignKey.PrincipalInvestmentStrategy);

            dto.SfCatMorningStar = await this.repositorySelectList.ByIdCM(dtoForeignKey.SfCatMorningStar);

            dto.SfCatSix = await this.repositorySelectList.ByIdCS(dtoForeignKey.SfCatSix);

            dto.SfCatBloomberg = await this.repositorySelectList.ByIdCB(dtoForeignKey.SfCatBloomberg);
        }
Пример #3
0
        public async Task <int> Create(CreateSubFundInputModel model)
        {
            SubFundPostDto dto = AutoMapperConfig.MapperInstance.Map <SubFundPostDto>(model);

            SubFundForeignKeysDto dtoForeignKey = AutoMapperConfig.MapperInstance.Map <SubFundForeignKeysDto>(model);

            dto.EndDate     = DateTimeExtensions.ToSqlFormat(model.EndDate);
            dto.ContainerId = await this.repositoryContainer.All()
                              .Where(f => f.FOfficialFundName == model.FundContainer)
                              .Select(fc => fc.FId)
                              .FirstOrDefaultAsync();

            await this.SetForeignKeys(dto, dtoForeignKey);

            var parameters = Deserializer.ImportParameters(
                EndpointsConstants.DisplaySub + EndpointsConstants.FundArea + EndpointsConstants.ActionCreate);

            var procedure = StringExtensions.BuildProcedure(
                SqlProcedureDictionary.CreateSubFund, parameters);

            SqlCommand command = this.AssignBaseParameters(dto, procedure, parameters);

            // Assign particular parameters
            command.Parameters.AddRange(new[]
            {
                new SqlParameter(parameters[29].Name, SqlDbType.Int)
                {
                    Value = dto.ContainerId
                },
                new SqlParameter(parameters[30].Name, SqlDbType.NVarChar)
                {
                    Value = dto.EndDate
                },
            });

            await this.sqlManager.ExecuteProcedure(command);

            var subFundId = this.repository.All()
                            .Where(sf => sf.SfOfficialSubFundName == dto.SubFundName)
                            .Select(sf => sf.SfId)
                            .FirstOrDefault();

            return(subFundId);
        }
Пример #4
0
        public async Task <int> Create(CreateSubFundInputModel model)
        {
            SubFundPostDto dto = AutoMapperConfig.MapperInstance.Map <SubFundPostDto>(model);

            SubFundForeignKeysDto dtoForeignKey = AutoMapperConfig.MapperInstance.Map <SubFundForeignKeysDto>(model);

            dto.EndDate     = DateTimeParser.ToSqlFormat(model.EndDate);
            dto.ContainerId = await this.repositoryContainer.All()
                              .Where(f => f.FOfficialFundName == model.FundContainer)
                              .Select(fc => fc.FId)
                              .FirstOrDefaultAsync();

            await this.SetForeignKeys(dto, dtoForeignKey);

            SqlCommand command = this.AssignBaseParameters(dto, SqlProcedureDictionary.CreateSubFund);

            // Assign particular parameters
            // Assign particular parameters
            command.Parameters.AddRange(new[]
            {
                new SqlParameter("@fundcontainer", SqlDbType.Int)
                {
                    Value = dto.ContainerId
                },
                new SqlParameter("@sf_endDate", SqlDbType.NVarChar)
                {
                    Value = dto.EndDate
                },
            });

            await this.sqlManager.ExecuteProcedure(command);

            var subFundId = this.repository.All()
                            .Where(sf => sf.SfOfficialSubFundName == dto.SubFundName)
                            .Select(sf => sf.SfId)
                            .FirstOrDefault();

            return(subFundId);
        }
Пример #5
0
        public async Task <int> Edit(EditSubFundInputModel model)
        {
            SubFundPostDto dto = AutoMapperConfig.MapperInstance.Map <SubFundPostDto>(model);

            SubFundForeignKeysDto dtoForeignKey = AutoMapperConfig.MapperInstance.Map <SubFundForeignKeysDto>(model);

            await this.SetForeignKeys(dto, dtoForeignKey);

            var parameters = Deserializer.ImportParameters(
                EndpointsConstants.DisplaySub + EndpointsConstants.FundArea + EndpointsConstants.ActionEdit);

            var procedure = StringExtensions.BuildProcedure(
                SqlProcedureDictionary.EditSubFund, parameters);

            SqlCommand command = this.AssignBaseParameters(dto, procedure, parameters);

            // Assign particular parameters
            command.Parameters.AddRange(new[]
            {
                new SqlParameter(parameters[29].Name, SqlDbType.Int)
                {
                    Value = dto.Id
                },
                new SqlParameter(parameters[30].Name, SqlDbType.NVarChar)
                {
                    Value = dto.CommentArea
                },
                new SqlParameter(parameters[31].Name, SqlDbType.NVarChar)
                {
                    Value = dto.CommentTitle
                },
            });

            await this.sqlManager.ExecuteProcedure(command);

            return(dto.Id);
        }