}//end method /// <summary> /// Adds a record to the database via a CostSql container. /// </summary> /// <param name="info"> The Cost business container that needs to be added. </param> /// <returns> The Cost ID of the item added to the database. </returns> public static int Add(Biz.Containers.Cost info) { var data = ConvertToDataContainer(info); Data.Sql.CostSql CostSql = new Data.Sql.CostSql(); int toReturn = CostSql.Add(data); return toReturn; }//end method
/// <summary> /// Returns the Cost ID instance that matches this ID /// </summary> /// <param name="ID">The ID of a Cost object we want retrieved. </param> /// <returns> A Cost business container with Cost ID record information. </returns> public static Biz.Containers.Cost Get(int ID) { Data.Sql.CostSql CostSql = new Data.Sql.CostSql(); Data.Containers.Cost data = CostSql.GetByID(ID); Biz.Containers.Cost toReturn = ConvertFromDataContainer(data); return toReturn; }//end method
}//end method /// <summary> /// Returns all Cost items /// </summary> /// <returns> An array of Cost Business containers. </returns> public static Biz.Containers.Cost[] GetAll() { Data.Sql.CostSql CostSql = new Data.Sql.CostSql(); Data.Containers.Cost[] data = CostSql.GetAll(); List<Biz.Containers.Cost> toReturn = new List<Biz.Containers.Cost>(); foreach (var info in data) { Biz.Containers.Cost Cost = ConvertFromDataContainer(info); toReturn.Add(Cost); } return toReturn.ToArray(); }//end method
}//end Method /// <summary> /// Converts Business Container object to Data Container object /// </summary> /// <param name="info">The business container Cost object. </param> /// <returns> The data container Cost object. </returns> internal static Data.Containers.Cost ConvertToDataContainer(Biz.Containers.Cost info) { return new Data.Containers.Cost() { ID = info.ID, IterationID = info.Iteration.ID, Date = info.Date, CurrentCost = info.CurrentCost, CostNext1 = info.CostNext1, CostNext2 = info.CostNext2, CostNext3 = info.CostNext3 }; }//end method
}//end method /// <summary> /// Updates a record via the CostSql container. /// </summary> /// <param name="info"> The Cost container object we want to update. </param> public static void Update(Biz.Containers.Cost info) { var data = ConvertToDataContainer(info); Data.Sql.CostSql CostSql = new Data.Sql.CostSql(); CostSql.Update(data); }//end method