Exemplo n.º 1
0
        /// <summary author="Jared Greenfield" created="2019/01/25">
        /// Adds a Recipe Line to the database.
        /// </summary>
        /// <updates>
        /// <update author="Jared Greenfield" date="2019/02/21">
        /// Added the validation and exception throwing
        /// </update>
        /// </updates>
        /// <param name="recipeItemLine">The line to be added to the database.</param>
        /// <param name="recipeID">The ID of the recipe it belongs to.</param>
        /// <exception cref="SQLException">Insert Fails (example of exception tag)</exception>
        /// <returns>Rows affected.</returns>
        public int CreateRecipeItemLine(RecipeItemLineVM recipeItemLine, int recipeID)
        {
            int returnedValue = 0;

            if (recipeItemLine.IsValid())
            {
                try
                {
                    returnedValue = _recipeAccessor.InsertRecipeItemLine(recipeItemLine, recipeID);
                }
                catch (Exception ex)
                {
                    ExceptionLogManager.getInstance().LogException(ex);
                    throw ex;
                }
            }
            else
            {
                throw new ArgumentException("This Recipe Line is invalid.");
            }

            return(returnedValue);
        }