ClearOneDalDemo/SettlementAttempt/QuickBaseSettlementAttemptDataAccess.cs

40 lines
1.3 KiB
C#
Raw Normal View History

2020-09-15 22:10:53 +00:00
using BinaryDad.AggregateDal.Models;
using System;
namespace BinaryDad.AggregateDal
{
public class QuickBaseSettlementAttemptDataAccess : EFSettlementAttemptDataAccess
2020-09-15 22:10:53 +00:00
{
public override bool AddAttempt(SettlementAttempt attempt)
2020-09-15 22:10:53 +00:00
{
// save to SQL first
base.AddAttempt(attempt);
2020-09-15 22:53:28 +00:00
// 1. create attempt in QuickBase ("Id" SQL PK should already be populated)
// 2. update the "RecordId" property/PK of attempt upon insertion
// 3. return if operation is successful
2020-09-15 22:10:53 +00:00
2020-09-15 22:53:28 +00:00
// auto-generated value from QB record insert
attempt.RecordId = 9999;
2020-09-15 22:10:53 +00:00
Console.WriteLine($"Adding attempt ID {attempt.RecordId} to Quickbase with SQL ID {attempt.Id}");
return true;
}
2020-09-29 20:48:07 +00:00
public override bool UpdateAttempt(SettlementAttempt attempt)
{
// update SQL first
base.UpdateAttempt(attempt);
// use mapping of the properties to build a request using QB API
// consider using reflection on the type, such as use of a [QuickBaseField(SettlementAttemptFieldMap.ClientFirstName)]
// to build list of mappings in QB API
Console.WriteLine($"Updating attempt ID {attempt.RecordId} to Quickbase with SQL ID {attempt.Id}");
return true;
}
2020-09-15 22:10:53 +00:00
}
}