An alternative to UBB.threads
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
FLocal/Common/actions/UpdateChange.cs

42 lines
1.3 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Web.Core.DB;
namespace FLocal.Common.actions {
public class UpdateChange : AbstractChange {
private readonly int id;
private Dictionary<string, AbstractFieldValue> data;
public UpdateChange(ISqlObjectTableSpec tableSpec, Dictionary<string, AbstractFieldValue> data, int id)
: base(tableSpec, from kvp in data select kvp.Value) {
this.id = id;
this.data = data;
}
public override int? getId() {
return this.id;
}
public override void Lock(Transaction transaction) {
Config.instance.mainConnection.lockRow(transaction, this.tableSpec, this.id.ToString());
}
protected override void doApply(Transaction transaction) {
Dictionary<string, string> row = Config.instance.mainConnection.LoadByIds(transaction, this.tableSpec, new List<string>() { this.id.ToString() })[0];
Dictionary<string, string> processedData = new Dictionary<string,string>();
foreach(KeyValuePair<string, AbstractFieldValue> kvp in this.data) {
processedData[kvp.Key] = kvp.Value.getStringRepresentation(row[kvp.Key]);
}
Config.instance.mainConnection.update(
transaction,
this.tableSpec,
this.id.ToString(),
processedData
);
}
}
}