class MarriageRegnRepository {

	public void save(MarriageRegn marriageRegn) {
	
		jdbcTemplate.update(INSERT_MARRIAGE_REGN_QUERY, new PreparedStatementSetter(){
			
			@Override
			public void setValues(PreparedStatement ps) throws SQLException {
				ps.setString(1, marriageRegn.getId());
				ps.setLong(2, marriageRegn.getRegnUnit().getId());
				ps.setLong(3, marriageRegn.getMarriageDate());
				ps.setString(4, marriageRegn.getVenue().toString());
				ps.setString(5, marriageRegn.getStreet());
				ps.setString(6, marriageRegn.getPlaceOfMarriage());
				ps.setString(7, marriageRegn.getLocality());
				ps.setString(8, marriageRegn.getCity());
				ps.setString(9, marriageRegn.getMarriagePhoto());
				ps.setLong(10, marriageRegn.getBridegroom().getId());
				ps.setLong(11, marriageRegn.getBride().getId());
				ps.setString(12, marriageRegn.getPriest().getName());
				ps.setLong(13, marriageRegn.getPriest().getReligion());
				ps.setString(14, marriageRegn.getPriest().getAddress());
				ps.setString(15, marriageRegn.getPriest().getAadhaar());
				ps.setString(16, marriageRegn.getPriest().getMobileNo());
				ps.setString(17, marriageRegn.getPriest().getEmail());
				ps.setString(18, marriageRegn.getSerialNo());
				ps.setString(19, marriageRegn.getVolumeNo());
				ps.setString(20, marriageRegn.getApplicationNumber());
				ps.setString(21, marriageRegn.getRegnNumber());
				ps.setLong(22, marriageRegn.getRegnDate());
				ps.setString(23, marriageRegn.getStatus().toString());
				ps.setString(24, marriageRegn.getSource().toString());
				ps.setString(25, marriageRegn.getStateId());
				ps.setBoolean(26, marriageRegn.getIsActive());
				ps.setString(27, marriageRegn.getTenantId());
				ps.setString(28, marriageRegn.getFee().getId());
				ps.setString(29, marriageRegn.getDemands().get(0).getId());
				ps.setLong(30, marriageRegn.getApprovalDetails().getDepartment());
				ps.setLong(31, marriageRegn.getApprovalDetails().getDesignation());
				ps.setLong(32, marriageRegn.getApprovalDetails().getAssignee());
				ps.setString(33, marriageRegn.getApprovalDetails().getAction());
				ps.setString(34, marriageRegn.getApprovalDetails().getStatus());
				ps.setString(35, marriageRegn.getApprovalDetails().getComments());
				ps.setString(36,marriageRegn.getAuditDetails().getCreatedBy());
				ps.setString(37, marriageRegn.getAuditDetails().getLastModifiedBy());
				ps.setLong(38,marriageRegn.getAuditDetails().getCreatedTime());
				ps.setLong(39, marriageRegn.getAuditDetails().getLastModifiedTime());
				
				
			}
		});
		
		if (marriageRegn.getWitnesses() != null)
			marriageRegn.getWitnesses().forEach(witness -> {
				witnessRepository.save(marriageRegn.getApplicationNumber(), marriageRegn.getTenantId(), witness);
			});
	}

}