public async Task <IActionResult> Edit(
            [Bind("Id", "InitialDate", "SubFundName", "CSSFCode", "Status",
                  "FACode", "TACode", "LEICode", "DBCode",
                  "FirstNavDate", "LastNavDate", "CSSFAuthDate", "ExpiryDate",
                  "CesrClass", "GeographicalFocus", "GlobalExposure", "CurrencyCode",
                  "NavFrequency", "ValuationDate", "CalculationDate", "Derivatives",
                  "DerivMarket", "DerivPurpose", "PrincipalAssetClass", "TypeOfMarket",
                  "PrincipalInvestmentStrategy", "ClearingCode", "SfCatMorningStar", "SfCatSix",
                  "SfCatBloomberg", "CommentTitle", "CommentArea", "RecaptchaValue")] EditSubFundInputModel model)
        {
            bool doesExistAtDate = await this.service.DoesExistAtDate(model.SubFundName, model.InitialDate);

            if (!this.ModelState.IsValid || doesExistAtDate)
            {
                if (doesExistAtDate)
                {
                    this.ShowError(this.sharedLocalizer.GetHtmlString(ErrorMessages.ExistingEntityAtDate));
                }

                this.SetViewDataValues();
                return(this.View(model));
            }

            var subFundId = await this.service.Edit(model);

            var date = DateTimeParser.ToWebFormat(model.InitialDate.AddDays(1));

            return(this.ShowInfo(
                       this.sharedLocalizer.GetHtmlString(InfoMessages.SuccessfulEdit),
                       GlobalConstants.SubFundDetailsRouteName,
                       new { area = GlobalConstants.SubFundAreaName, id = subFundId, date = date }));
        }
        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);
        }
Example #3
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);
        }