/// <summary> /// Delete the specified contract formula. /// </summary> /// <param name="contractFormula">The contract formula to be deleted.</param> /// <returns>Number of affected rows.</returns> public static int Delete(ContractFormula contractFormula) { using (SqlConnection connection = SamenSterkerDB.GetConnection()) { return connection.Execute( sql: "DELETE FROM ContractFormula WHERE Id = @Id", param: contractFormula ); } }
/// <summary> /// Save the specified contract formula. /// </summary> /// <param name="contractFormula">The contract formula to be saved.</param> /// <returns>Number of affected rows.</returns> public static int Save(ContractFormula contractFormula) { using (SqlConnection connection = SamenSterkerDB.GetConnection()) { int rowsAffected = connection.Execute( sql: isNew(contractFormula) ? insertCommand : updateCommand, param: contractFormula ); //SetIdentity<int>(connection, id => subCategory.Id = id); return rowsAffected; } }
private static bool isNew(ContractFormula contractFormula) { return contractFormula.Id == 0; }
private static Contract Mapper(Contract ct, Company cmp, ContractFormula f) { ct.Company = cmp; ct.Formula = f; return ct; }