Exemple #1
0
        /// <summary>
        /// Adds the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        public void Add(Sample entity)
        {
            var sample = entity;

            Debug.Assert(sample != null, "sample != null");
            using (var connection = new SqlConnection(DbConnection))
            {
                using (var command = new SqlCommand("PaSampleInsert", connection))
                {
                    var sqlParams = new List <SqlParameter>();
                    SqlHelper.AddReturnPara("@return_value", sqlParams);

                    SqlHelper.AddVarcharPara(sample.SessionKey, "@SessionKey", sqlParams);

                    SqlHelper.AddVarcharPara(sample.ClaimTypeDescription, "@ClaimTypeDescription", sqlParams);
                    SqlHelper.AddVarcharPara(sample.ContractTypeDescription, "@ContractTypeDescription", sqlParams);
                    SqlHelper.AddVarcharPara(sample.SiteDescription, "@SiteDescription", sqlParams);
                    SqlHelper.AddVarcharPara(sample.EsaDescription, "@EsaDescription", sqlParams);
                    SqlHelper.AddVarcharPara(sample.OrgDescription, "@OrgDescription", sqlParams);

                    SqlHelper.AddBigIntPara(sample.ClaimId, "@ClaimId", sqlParams);
                    SqlHelper.AddIntPara(sample.ClaimSequenceNumber, "@ClaimSequenceNumber", sqlParams);
                    SqlHelper.AddVarcharPara(sample.ClaimType, "@ClaimType", sqlParams);
                    SqlHelper.AddMoneyPara(sample.ClaimAmount, "@ClaimMoney", sqlParams);

                    SqlHelper.AddVarcharPara(sample.SiteCode, "@SiteCode", sqlParams);
                    SqlHelper.AddVarcharPara(sample.SupervisingSiteCode, "@SupervisingSiteCode", sqlParams);
                    SqlHelper.AddVarcharPara(sample.OrgCode, "@OrgCode", sqlParams);

                    SqlHelper.AddBigIntPara(sample.ActivityId, "@ActivityId", sqlParams);
                    SqlHelper.AddDatePara(sample.ClaimCreationDate, "@ClaimCreationDate", sqlParams);

                    SqlHelper.AddVarcharPara(sample.StatusCode, "@ClaimStatusCode", sqlParams);
                    SqlHelper.AddVarcharPara(sample.StatusCodeDescription, "@ClaimStatusDescription", sqlParams);

                    SqlHelper.AddVarcharPara(sample.StateCode, "@StateCode", sqlParams);
                    SqlHelper.AddVarcharPara(sample.ManagedBy, "@ManagedBy", sqlParams);
                    SqlHelper.AddVarcharPara(sample.ContractId, "@ContractId", sqlParams);
                    SqlHelper.AddVarcharPara(sample.ContractType, "@ContractType", sqlParams);
                    SqlHelper.AddVarcharPara(sample.ContractTitle, "@ContractTitle", sqlParams);

                    SqlHelper.AddVarcharPara(sample.EsaCode, "@EsaCode", sqlParams);
                    SqlHelper.AddBigIntPara(sample.JobseekerId, "@JobseekerId", sqlParams);
                    SqlHelper.AddVarcharPara(sample.GivenName, "@GivenName", sqlParams);
                    SqlHelper.AddVarcharPara(sample.Surname, "@LastName", sqlParams);

                    SqlHelper.AddCharPara(sample.AutoSpecialClaimFlag, "@AutoSpecialClaimFlag", sqlParams);
                    SqlHelper.AddCharPara(sample.ManSpecialClaimFlag, "@ManualSpecialClaimFlag", sqlParams);

                    SqlHelper.AddVarcharPara(sample.CreatedBy, "@CreatedBy", sqlParams);

                    //  Output parameters
                    var paramId = new SqlParameter("@Id", SqlDbType.Int)
                    {
                        Direction = ParameterDirection.InputOutput,
                        Value     = 0
                    };
                    sqlParams.Add(paramId);

                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(sqlParams.ToArray());

                    connection.Open();

                    command.ExecuteNonQuery();

                    if (((Int32)command.Parameters["@return_value"].Value) != 0)
                    {
                        return;
                    }

                    sample.Id = (int)paramId.Value;
                }
            }
        }