87 lines
2.2 KiB
C#
87 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace JRCookbookBusiness
|
|
{
|
|
public class IngredientMeasure
|
|
{
|
|
public Guid? ingredientID = null;
|
|
public Guid? measureID = null;
|
|
public Single gramWeight = 0;
|
|
|
|
|
|
public IngredientMeasure()
|
|
{
|
|
}
|
|
|
|
public IngredientMeasure(Guid ingredientID, Guid measureID)
|
|
{
|
|
PopulateByID(ingredientID, measureID);
|
|
}
|
|
|
|
public static IngredientMeasure GetIngredientMeasureByID(Guid ingredientID, Guid measureID)
|
|
{
|
|
return new IngredientMeasure(ingredientID, measureID);
|
|
}
|
|
|
|
private void PopulateByID(Guid ingredientID, Guid measureID)
|
|
{
|
|
DataSet recordSet;
|
|
|
|
recordSet = clsDatabaseLayer.GetDatabaseLayer().GetIngredientMeasureByID(ingredientID, measureID);
|
|
|
|
if (recordSet.Tables[0].Rows.Count > 0)
|
|
{
|
|
DataRow ldbrwRow;
|
|
ldbrwRow = recordSet.Tables[0].Rows[0];
|
|
|
|
PopulateFromDataRow(ldbrwRow);
|
|
}
|
|
|
|
}
|
|
|
|
public static IngredientMeasure GetIngredientMeasureByDataRow(DataRow row)
|
|
{
|
|
var newIngredientMeasure = new IngredientMeasure();
|
|
newIngredientMeasure.PopulateFromDataRow(row);
|
|
return newIngredientMeasure;
|
|
}
|
|
|
|
|
|
private void PopulateFromDataRow(DataRow dataRow)
|
|
{
|
|
InitializeAllFields();
|
|
|
|
if (dataRow.IsNull("ingredientID"))
|
|
ingredientID = null;
|
|
else
|
|
ingredientID = (Guid)dataRow["ingredientID"];
|
|
|
|
if (dataRow.IsNull("measureID"))
|
|
measureID = null;
|
|
else
|
|
measureID = (Guid)dataRow["measureID"];
|
|
|
|
if (dataRow.IsNull("gramweight"))
|
|
gramWeight = 0;
|
|
else
|
|
gramWeight = (Single)dataRow["gramweight"];
|
|
|
|
|
|
}
|
|
|
|
private void InitializeAllFields()
|
|
{
|
|
ingredientID = null;
|
|
measureID = null;
|
|
gramWeight = 0;
|
|
}
|
|
|
|
}
|
|
}
|