Esempio n. 1
0
        public void OutPutStram(string companyId)
        {
            string type = HttpContext.Current.Request.QueryString["type"];

            HttpContext.Current.Response.ContentType = "image/jpeg";
            CompanyDocument companyDocument = null;

            if (!string.IsNullOrWhiteSpace(companyId))
            {
                companyDocument = AccountCombineService.QueryCompanyDocument(Guid.Parse(companyId));
            }
            if (companyDocument != null)
            {
                if (type == "bussiness" && companyDocument.BussinessLicense != null && companyDocument.BussinessLicense.Length > 0)
                {
                    HttpContext.Current.Response.BinaryWrite(companyDocument.BussinessLicense);
                }
                if (type == "certNo" && companyDocument.CertLicense != null && companyDocument.CertLicense.Length > 0)
                {
                    HttpContext.Current.Response.BinaryWrite(companyDocument.CertLicense);
                }
                if (type == "iata" && companyDocument.IATALicense != null && companyDocument.IATALicense.Length > 0)
                {
                    HttpContext.Current.Response.BinaryWrite(companyDocument.IATALicense);
                }
            }
        }
        public async Task <ActionResult> Create([FromBody] CompanyDocument company)
        {
            var createdCompany = await _companyService.CreateAsync(_companyDocumentConverter.ToCompanyDto(company));

            return(CreatedAtAction(nameof(GetById), new { id = createdCompany.Id },
                                   _companyDocumentConverter.ToCompanyDocument(createdCompany)));
        }
Esempio n. 3
0
        public int Save(CompanyDocument document)
        {
            string sql = @"IF NOT EXISTS(SELECT NULL FROM [dbo].[T_CompanyDocument] WHERE Company =@Company) INSERT INTO [dbo].[T_CompanyDocument]([Company],[BussinessLicense] ,
                          [IATALicense],[CertLicense],[BussinessTime]) VALUES(@Company,@BussinessLicense ,@IATALicense,@CertLicense,@BussinessTime) ELSE UPDATE [dbo].[T_CompanyDocument]
                           SET [BussinessLicense] = @BussinessLicense ,[IATALicense] = @IATALicense,[CertLicense] = @CertLicense,[BussinessTime] = @BussinessTime
                           WHERE  [Company] = @Company";

            using (var dbOperator = new DbOperator(Provider, ConnectionString))
            {
                dbOperator.AddParameter("Company", document.Company);
                if (document.BussinessLicense != null && document.BussinessLicense.Length > 0)
                {
                    dbOperator.AddParameter("BussinessLicense", document.BussinessLicense);
                }
                else
                {
                    dbOperator.AddParameter("BussinessLicense", DBNull.Value, DbType.Binary);
                }
                if (document.IATALicense != null && document.IATALicense.Length > 0)
                {
                    dbOperator.AddParameter("IATALicense", document.IATALicense);
                }
                else
                {
                    dbOperator.AddParameter("IATALicense", DBNull.Value, DbType.Binary);
                }
                if (document.CertLicense != null && document.CertLicense.Length > 0)
                {
                    dbOperator.AddParameter("CertLicense", document.CertLicense);
                }
                else
                {
                    dbOperator.AddParameter("CertLicense", DBNull.Value, DbType.Binary);
                }
                if (document.BussinessTime.HasValue)
                {
                    dbOperator.AddParameter("BussinessTime", document.BussinessTime);
                }
                else
                {
                    dbOperator.AddParameter("BussinessTime", DBNull.Value);
                }
                return(dbOperator.ExecuteNonQuery(sql));
            }
        }
        public async Task <ActionResult> Edit(int id, [FromBody] CompanyDocument company)
        {
            if (id != company.Id)
            {
                return(BadRequest());
            }

            var companyDto = await _companyService.GetByIdAsync(id);

            if (companyDto == null)
            {
                return(NotFound());
            }

            await _companyService.EditAsync(id, _companyDocumentConverter.ToCompanyDto(company));

            return(NoContent());
        }
Esempio n. 5
0
        public CompanyDocument Query(Guid companyId)
        {
            CompanyDocument document = null;
            string          sql      = @"SELECT [Company],[BussinessLicense] ,[IATALicense],[CertLicense],[BussinessTime] FROM [dbo].[T_CompanyDocument] WHERE Company = @Company";

            using (var dbOperator = new DbOperator(Provider, ConnectionString)){
                dbOperator.AddParameter("Company", companyId);
                using (var reader = dbOperator.ExecuteReader(sql)) {
                    while (reader.Read())
                    {
                        document         = new CompanyDocument();
                        document.Company = reader.GetGuid(0);
                        if (!reader.IsDBNull(1))
                        {
                            var    length = reader.GetBytes(1, 0, null, 0, 0);
                            byte[] buffer = new byte[length];
                            reader.GetBytes(1, 0, buffer, 0, (int)length);
                            document.BussinessLicense = buffer;
                        }
                        if (!reader.IsDBNull(2))
                        {
                            var    length = reader.GetBytes(2, 0, null, 0, 0);
                            byte[] buffer = new byte[length];
                            reader.GetBytes(2, 0, buffer, 0, (int)length);
                            document.IATALicense = buffer;
                        }
                        if (!reader.IsDBNull(3))
                        {
                            var    length = reader.GetBytes(3, 0, null, 0, 0);
                            byte[] buffer = new byte[length];
                            reader.GetBytes(3, 0, buffer, 0, (int)length);
                            document.CertLicense = buffer;
                        }
                        if (!reader.IsDBNull(4))
                        {
                            document.BussinessTime = reader.GetInt32(4);
                        }
                    }
                }
            }
            return(document);
        }
 public CompanyDto ToCompanyDto(CompanyDocument companyDocument) =>
 new CompanyDto
 {
     Id   = companyDocument.Id,
     Name = companyDocument.Name
 };