示例#1
0
        public async Task <IActionResult> OnPostUploadAgreementAsync(
            [Bind("AgrType", "AgreementsFileTypes", "AgreementsStatus", "Companies", "ContractDate",
                  "ActivationDate", "ExpirationDate", "Company", "Status", "FileToUpload",
                  "Date", "Id", "RouteName", "AreaName")] UploadAgreementInputModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.PartialView(UploadAgreementPartialView, model));
            }

            string path = await FileHelpers.ProcessFormFile(model.FileToUpload, this.ModelState, this.permittedExtensions,
                                                            this.fileSizeLimit, this.environment.WebRootPath, model.AreaName, true);

            if (!this.ModelState.IsValid)
            {
                return(this.PartialView(UploadAgreementPartialView, model));
            }

            var dto = AutoMapperConfig.MapperInstance.Map <UploadOnSuccessDto>(model);

            //dto.FileId =

            await this.service.UploadAgreement(model);

            using (var stream = new FileStream(path, FileMode.Create))
            {
                await model.FileToUpload.CopyToAsync(stream);

                stream.Close();
            }

            return(this.Json(new { success = true, dto = dto }));
        }
示例#2
0
        public static UploadAgreementInputModel GenerateAgreement(int fundId, string activationDate, string agrType = "Management Company Agreement")
        {
            var file = new FormFile(new MemoryStream(Encoding.UTF8.GetBytes("This is a test agreement")), 0, 0, "Data", "test.pdf")
            {
                Headers     = new HeaderDictionary(),
                ContentType = "text/plain"
            };

            var model = new UploadAgreementInputModel()
            {
                Id             = fundId,
                AgrType        = agrType,
                ContractDate   = activationDate,
                ActivationDate = activationDate,
                Company        = "CACEIS Bank Luxembourg",
                Status         = "Active",
                FileToUpload   = file,
                AreaName       = "Fund"
            };

            return(model);
        }
示例#3
0
        // ________________________________________________________
        //
        // Agreements
        public async Task UploadAgreement(UploadAgreementInputModel model)
        {
            UploadAgreementDto dto = AutoMapperConfig.MapperInstance.Map <UploadAgreementDto>(model);

            dto.AgreementType = await this.repository.ByIdAgreementType(model.AgrType);

            dto.Status = await this.repository.ByIdStatus(model.Status);

            dto.Company = await this.repository.ByIdCompany(model.Company);

            Validator.ArgumentNullExceptionInt(dto.AgreementType, ErrorMessages.InvalidAgrType);
            Validator.ArgumentNullExceptionInt(dto.Status, ErrorMessages.InvalidStatus);
            Validator.ArgumentNullExceptionInt(dto.Company, ErrorMessages.InvalidStatus);

            string query = StringSwapper.ByArea(model.AreaName,
                                                SqlProcedureDictionary.AgreementFund,
                                                SqlProcedureDictionary.AgreementSubFund,
                                                SqlProcedureDictionary.AgreementShareClass);

            query += " @file_name, @entity_id, @file_ext, @activity_type_id, @contract_date,@activation_date, " +
                     "@expiration_date, @company_id, @status";

            SqlCommand command = new SqlCommand(query);

            command.Parameters.AddRange(new[]
            {
                new SqlParameter("@file_name", SqlDbType.NVarChar)
                {
                    Value = dto.FileName
                },
                new SqlParameter("@entity_id", SqlDbType.Int)
                {
                    Value = dto.Id
                },
                new SqlParameter("@file_ext", SqlDbType.NVarChar)
                {
                    Value = dto.FileExt
                },
                new SqlParameter("@activity_type_id", SqlDbType.Int)
                {
                    Value = dto.AgreementType
                },
                new SqlParameter("@contract_date", SqlDbType.NVarChar)
                {
                    Value = dto.ContractDate
                },
                new SqlParameter("@activation_date", SqlDbType.NVarChar)
                {
                    Value = dto.ActivationDate
                },
                new SqlParameter("@expiration_date", SqlDbType.NVarChar)
                {
                    Value = dto.ExpirationDate
                },
                new SqlParameter("@company_id", SqlDbType.Int)
                {
                    Value = dto.Company
                },
                new SqlParameter("@status", SqlDbType.Int)
                {
                    Value = dto.Status
                },
            });

            await this.sqlManager.ExecuteProcedure(command);
        }