/// <summary> /// Updates <see cref="Item"/>'s <see cref="MeassurementUnit"/> /// </summary> public void UpdateUnitOfMeassure(int itemID, MeassurementUnit unit) { using (IDbConnection connection = new SQLiteConnection(DbConnectionString)) { connection.Open(); connection.Execute(new CommandDefinition($"UPDATE {DbItemMetadata.DName} SET {DbItemMetadata.DName}.{nameof(DbItemMetadata.UnitOfMeassure)} = {unit.ToString()}")); } }
/// <summary> /// Sets the unit of measure for the item, can update the database /// </summary> public void SetUnitOfMeassure(MeassurementUnit unit, bool updateDatabase = false) { UnitOfMeassure = unit; if (updateDatabase) { DatabaseAccess.Access.UpdateUnitOfMeassure(ID, unit); } }
public void WriteUnitOfMeassureForItemToDatabase(string itemName, MeassurementUnit unit) { foreach (JToken tok in itemDatabaseJson) { if (tok[nameof(Item.userFriendlyName)].Value <string>() == itemName) { tok[nameof(Item.unitOfMeassure)] = unit.ToString(); } } File.WriteAllText(itemDatabaseFile.FullName, itemDatabaseJson.ToString()); itemDatabase[itemName].SetUnitOfMeassure(unit); }
internal void SetUnitOfMeassure(MeassurementUnit unit) { unitOfMeassure = unit; }