public async Task SaveLevyDeclaration(LevyDeclarationViewModel levyDeclaration) { await WithConnection(async c => { var parameters = new DynamicParameters(); parameters.Add("@DasAccountId", levyDeclaration.HashedAccountId, DbType.String); parameters.Add("@LevyDeclarationId", levyDeclaration.Id, DbType.Int64); parameters.Add("@PayeSchemeReference", levyDeclaration.PayeSchemeReference, DbType.String); parameters.Add("@LevyDueYearToDate", levyDeclaration.LevyDueYtd, DbType.Decimal); parameters.Add("@LevyAllowanceForYear", levyDeclaration.LevyAllowanceForYear, DbType.Decimal); parameters.Add("@SubmissionDate", levyDeclaration.SubmissionDate, DbType.DateTime); parameters.Add("@SubmissionId", levyDeclaration.SubmissionId, DbType.Int64); parameters.Add("@PayrollYear", levyDeclaration.PayrollYear, DbType.String); parameters.Add("@PayrollMonth", levyDeclaration.PayrollMonth, DbType.Int16); parameters.Add("@CreatedDate", levyDeclaration.CreatedDate, DbType.DateTime); parameters.Add("@EndOfYearAdjustment", levyDeclaration.EndOfYearAdjustment, DbType.Boolean); parameters.Add("@EndOfYearAdjustmentAmount", levyDeclaration.EndOfYearAdjustmentAmount, DbType.Decimal); parameters.Add("@DateCeased", levyDeclaration.DateCeased, DbType.DateTime); parameters.Add("@InactiveFrom", levyDeclaration.InactiveFrom, DbType.DateTime); parameters.Add("@InactiveTo", levyDeclaration.InactiveTo, DbType.DateTime); parameters.Add("@HmrcSubmissionId", levyDeclaration.HmrcSubmissionId, DbType.Int64); parameters.Add("@EnglishFraction", levyDeclaration.EnglishFraction, DbType.Decimal); parameters.Add("@TopupPercentage", levyDeclaration.TopUpPercentage, DbType.Decimal); parameters.Add("@TopupAmount", levyDeclaration.TopUp, DbType.Decimal); parameters.Add("@LevyDeclaredInMonth", levyDeclaration.LevyDeclaredInMonth, DbType.Decimal); parameters.Add("@LevyAvailableInMonth", levyDeclaration.TotalAmount, DbType.Decimal); return(await c.ExecuteAsync( sql: "[Data_Load].[SaveLevyDeclaration]", param: parameters, commandType: CommandType.StoredProcedure)); }); }
public void InsertIntoLevyDeclarations(dynamic value, ICollection <string> columns) { var levyDeclaration = new LevyDeclarationViewModel(); levyDeclaration.HashedAccountId = columns.Contains("DasAccountId") ? value.DasAccountId : null; levyDeclaration.Id = columns.Contains("LevyDeclarationId") ? value.LevyDeclarationId : (long)43256; levyDeclaration.PayeSchemeReference = columns.Contains("PayeSchemeReference") ? value.PayeSchemeReference : null; levyDeclaration.LevyDueYtd = columns.Contains("LevyDueYearToDate") ? ConvertToType <decimal>(value.LevyDueYearToDate) : null; levyDeclaration.LevyAllowanceForYear = columns.Contains("LevyAllowanceForYear") ? ConvertToType <decimal>(value.LevyAllowanceForYear) : null; levyDeclaration.SubmissionDate = columns.Contains("SubmissionDate") ? value.SubmissionDate : DateTime.Now.AddDays(-100); levyDeclaration.SubmissionId = columns.Contains("SubmissionId") ? value.SubmissionId : (long)66666; levyDeclaration.PayrollYear = columns.Contains("PayrollYear") ? value.PayrollYear.ToString() : null; levyDeclaration.PayrollMonth = columns.Contains("PayrollMonth") ? ConvertToType <short>(value.PayrollMonth) : null; levyDeclaration.CreatedDate = columns.Contains("CreatedDate") ? value.CreatedDate : DateTime.Now.AddDays(-250); levyDeclaration.EndOfYearAdjustment = columns.Contains("EndOfYearAdjustment") ? value.EndOfYearAdjustment : default(bool); levyDeclaration.EndOfYearAdjustmentAmount = columns.Contains("EndOfYearAdjustmentAmount") ? ConvertToType <decimal>(value.EndOfYearAdjustmentAmount) : null; levyDeclaration.DateCeased = columns.Contains("DateCeased") ? value.DateCeased : null; levyDeclaration.InactiveFrom = columns.Contains("InactiveFrom") ? value.InactiveFrom : null; levyDeclaration.InactiveTo = columns.Contains("InactiveTo") ? value.InactiveTo : null; levyDeclaration.HmrcSubmissionId = columns.Contains("HmrcSubmissionId") ? ConvertToType <long>(value.HmrcSubmissionId) : (long)777777; levyDeclaration.EnglishFraction = columns.Contains("EnglishFraction") ? ConvertToType <decimal>(value.EnglishFraction) : (decimal)1.00000; levyDeclaration.TopUpPercentage = columns.Contains("TopupPercentage") ? ConvertToType <decimal>(value.TopupPercentage) : (decimal)0.10000; levyDeclaration.TopUp = columns.Contains("TopupAmount") ? ConvertToType <decimal>(value.TopupAmount) : (decimal)100.0000; levyDeclaration.LevyDeclaredInMonth = columns.Contains("LevyDeclaredInMonth") ? ConvertToType <decimal>(value.LevyDeclaredInMonth) : (decimal)10000.00000; levyDeclaration.TotalAmount = columns.Contains("LevyAvailableInMonth") ? ConvertToType <decimal>(value.LevyAvailableInMonth) : (decimal)11000.00000; var levyrepo = new LevyDeclarationRepository(_connectionString); levyrepo.SaveLevyDeclaration(levyDeclaration).Wait(); }