Пример #1
0
        public async Task <int> Edit(EditShareClassInputModel model)
        {
            ShareClassPostDto        dto           = AutoMapperConfig.MapperInstance.Map <ShareClassPostDto>(model);
            ShareClassForeignKeysDto dtoForeignKey = AutoMapperConfig.MapperInstance.Map <ShareClassForeignKeysDto>(model);

            await this.SetForeignKeys(dto, dtoForeignKey);

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

            // Assign particular parameters
            command.Parameters.AddRange(new[]
            {
                new SqlParameter("@sc_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("@sc_shortShareClassName", SqlDbType.NVarChar)
                {
                    Value = dto.ShareClassName
                },
            });

            await this.sqlManager.ExecuteProcedure(command);

            return(dto.Id);
        }
Пример #2
0
        public async Task <int> Edit(EditShareClassInputModel model)
        {
            ShareClassPostDto        dto           = AutoMapperConfig.MapperInstance.Map <ShareClassPostDto>(model);
            ShareClassForeignKeysDto dtoForeignKey = AutoMapperConfig.MapperInstance.Map <ShareClassForeignKeysDto>(model);

            await this.SetForeignKeys(dto, dtoForeignKey);

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

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

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

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

            await this.sqlManager.ExecuteProcedure(command);

            return(dto.Id);
        }
Пример #3
0
        private async Task SetForeignKeys(ShareClassPostDto dto, ShareClassForeignKeysDto dtoForeignKey)
        {
            dto.Status = await this.repositorySelectList.ByIdStatus(dtoForeignKey.Status);

            dto.ShareType = await this.repositorySelectList.ByIdShareType(dtoForeignKey.ShareType);

            dto.InvestorType = await this.repositorySelectList.ByIdInvestorType(dtoForeignKey.InvestorType);

            dto.CountryIssue = await this.repositorySelectList.ByNameCountry(dtoForeignKey.CountryIssue);

            dto.CountryRisk = await this.repositorySelectList.ByNameCountry(dtoForeignKey.CountryRisk);
        }
Пример #4
0
        public async Task <int> Create(CreateShareClassInputModel model)
        {
            ShareClassPostDto        dto           = AutoMapperConfig.MapperInstance.Map <ShareClassPostDto>(model);
            ShareClassForeignKeysDto dtoForeignKey = AutoMapperConfig.MapperInstance.Map <ShareClassForeignKeysDto>(model);

            dto.EndDate     = DateTimeExtensions.ToSqlFormat(model.EndDate);
            dto.ContainerId = await this.repositoryContainer.All()
                              .Where(f => f.SfOfficialSubFundName == model.SubFundContainer)
                              .Select(fc => fc.SfId)
                              .FirstOrDefaultAsync();

            await this.SetForeignKeys(dto, dtoForeignKey);

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

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

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

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

            await this.sqlManager.ExecuteProcedure(command);

            var subFundId = this.repository.All()
                            .Where(sf => sf.ScOfficialShareClassName == dto.ShareClassName)
                            .Select(sf => sf.ScId)
                            .FirstOrDefault();

            return(subFundId);
        }