Exemplo n.º 1
0
        public async Task <int> Edit(EditFundInputModel model)
        {
            FundPostDto dto = AutoMapperConfig.MapperInstance.Map <FundPostDto>(model);

            await this.SetForeignKeys(dto, model.Status, model.LegalForm, model.LegalVehicle,
                                      model.LegalType, model.CompanyTypeDesc);

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

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

            await this.sqlManager.ExecuteProcedure(command);

            return(dto.Id);
        }
        public async Task <IActionResult> Edit(
            [Bind("Id", "InitialDate", "FundName", "CSSFCode", "Status",
                  "LegalForm", "LegalVehicle", "LegalType", "FACode", "FundAdmin",
                  "DEPCode", "TACode", "CompanyTypeDesc", "TinNumber", "LEICode",
                  "RegNumber", "VATRegNumber", "VATIdentificationNumber", "IBICNumber",
                  "CommentTitle", "CommentArea", "RecaptchaValue")] EditFundInputModel model)
        {
            bool doesExistAtDate = await this.service.DoesExistAtDate(model.FundName, model.InitialDate);

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

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

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

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

            return(this.ShowInfo(
                       this.sharedLocalizer.GetHtmlString(InfoMessages.SuccessfulEdit),
                       EndpointsConstants.RouteDetails + EndpointsConstants.FundArea,
                       new { area = EndpointsConstants.FundArea, id = fundId, date = date }));
        }
Exemplo n.º 3
0
        public async Task <int> Edit(EditFundInputModel model)
        {
            FundPostDto dto = AutoMapperConfig.MapperInstance.Map <FundPostDto>(model);

            await this.SetForeignKeys(dto, model.Status, model.LegalForm, model.LegalVehicle,
                                      model.LegalType, model.CompanyTypeDesc);

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

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

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

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

            await this.sqlManager.ExecuteProcedure(command);

            return(dto.Id);
        }