public RecipeDomain GetRecipeByRecipeId(int RecipeId) { RecipeDomain RecipeDomain = null; MediaDomain MediaDomain = null; IngredientDomain IngredientDomain = null; DataProvider.ExecuteCmd(GetConnection, "dbo.Recipes_GetByRecipeId" , inputParamMapper : delegate(SqlParameterCollection paramcollection) { paramcollection.AddWithValue("@Id", RecipeId); }, map : delegate(IDataReader reader, short set) { if (set == 0) { int startingIndex = 0; RecipeDomain = new RecipeDomain(); RecipeDomain.Id = reader.GetSafeInt32(startingIndex++); RecipeDomain.CreatedDate = reader.GetSafeDateTime(startingIndex++); RecipeDomain.Name = reader.GetSafeString(startingIndex++); RecipeDomain.Description = reader.GetSafeString(startingIndex++); RecipeDomain.Directions = reader.GetSafeString(startingIndex++); RecipeDomain.Preptime = reader.GetSafeInt32(startingIndex++); RecipeDomain.Totaltime = reader.GetSafeInt32(startingIndex++); RecipeDomain.NumberOfServings = reader.GetSafeInt32(startingIndex++); RecipeDomain.UserId = reader.GetSafeString(startingIndex++); MediaDomain = new MediaDomain(); MediaDomain.Id = reader.GetSafeInt32(startingIndex++); MediaDomain.DataType = reader.GetSafeString(startingIndex++); MediaDomain.Url = reader.GetSafeString(startingIndex++); MediaDomain.Created = reader.GetSafeDateTime(startingIndex++); RecipeDomain.Media = MediaDomain; if (RecipeDomain == null) { RecipeDomain = new RecipeDomain(); } } else if (set == 1) { IngredientDomain = new IngredientDomain(); int startingIndex = 0; IngredientDomain.Id = reader.GetSafeInt32(startingIndex++); IngredientDomain.RecipeId = reader.GetSafeInt32(startingIndex++); IngredientDomain.Name = reader.GetSafeString(startingIndex++); IngredientDomain.MeasurementType = reader.GetSafeEnum <IngredientMeasurementType>(startingIndex++); IngredientDomain.Quantity = reader.GetSafeInt32(startingIndex++); RecipeDomain.Ingredients.Add(IngredientDomain); } }); return(RecipeDomain); }
private RecipesController CreateRecipesController(RecipesContext recipesContext) { var databaseActions = new DatabaseActions(recipesContext); var ingredientDomain = new IngredientDomain(databaseActions); var recipesDomain = new RecipesDomain(databaseActions, ingredientDomain); return(new RecipesController(recipesDomain)); }
private RecipesController CreateRecipesController() { var options = _fixture.Options; var recipesContext = new RecipesContext(options); var databaseActions = new DatabaseActions(recipesContext); var ingredientDomain = new IngredientDomain(databaseActions); var recipesDomain = new RecipesDomain(databaseActions, ingredientDomain); return(new RecipesController(recipesDomain)); }