// clear the current list of ingredients for a given recipe and add the ones based on the file to ingest private static void addIngredients(RecipeObj recipe) { // clear the current list using (var context = new WoolworthsDBDataContext()) { var ingredToDel = context.RecipeIngredients.Where(r => r.RecipeID == recipe.RecipeID); context.RecipeIngredients.DeleteAllOnSubmit(ingredToDel); context.SubmitChanges(); } if (recipe.Ingredients == null) { return; } using (var context = new WoolworthsDBDataContext()) { foreach (var ingred in recipe.Ingredients.Select(obj => new RecipeIngredient() { Description = obj.Ingredient, Number = obj.IngredientID, ProductArticle = obj.ProductID, RecipeID = recipe.RecipeID })) { context.RecipeIngredients.InsertOnSubmit(ingred); } context.SubmitChanges(); } }
// clear the current list of methods for a given recipe and add the ones based on the file to ingest private static void addMethods(RecipeObj recipe) { // clear the current list using (var context = new WoolworthsDBDataContext()) { var methodToDel = context.RecipeMethods.Where(r => r.RecipeID == recipe.RecipeID); context.RecipeMethods.DeleteAllOnSubmit(methodToDel); context.SubmitChanges(); } if (recipe.Methods == null) { return; } using (var context = new WoolworthsDBDataContext()) { foreach (var method in recipe.Methods.Select(obj => new RecipeMethod() { Description = obj.Step, Number = obj.StepID, RecipeID = recipe.RecipeID })) { context.RecipeMethods.InsertOnSubmit(method); } context.SubmitChanges(); } }
// delete a given recipe by id private static void deleteRecipe(int id) { using (var context = new WoolworthsDBDataContext()) { context.p_DeleteRecipe(id); } }
protected override void ExecuteResetProc() { using (var db = new WoolworthsDBDataContext()) { db.CommandTimeout = CommandTimeoutInSeconds.Value; db.p_Import_MasterProductLoc_ProductLocation_Reset(); } }
protected override void ExecuteResetProc() { using (var context = new WoolworthsDBDataContext()) { context.CommandTimeout = CommandTimeoutInSeconds.Value; context.p_Import_PriceData_ProductRangePricing_Reset(); } }
protected override void ExecuteResetProc() { using (var db = new WoolworthsDBDataContext()) { db.CommandTimeout = CommandTimeoutInSeconds.Value; db.p_ImportWeeklySpecial_Reset(); } }
protected override void ExecuteResetProc() { using (var db = new WoolworthsDBDataContext()) { db.CommandTimeout = CommandTimeoutInSeconds.Value; db.p_ImportOffer_Reset(); //for now } }
protected override void ExecuteResetProc() { using (var db = new WoolworthsDBDataContext()) { db.CommandTimeout = CommandTimeoutInSeconds.Value; db.p_ImportProductLocationDaily_Reset(); } }
protected override void ExecuteResetProc() { using (var context = new WoolworthsDBDataContext()) { context.CommandTimeout = CommandTimeoutInSeconds.Value; context.p_Import_OncBpOffers_BonusPoints_Reset(); } }
protected override void ExecuteResetProc() { using (var context = new WoolworthsDBDataContext()) { context.CommandTimeout = CommandTimeoutInSeconds.Value; context.p_Import_OnlineSellType_Reset(); } }
protected override void ExecuteResetProc() { using (var context = new WoolworthsDBDataContext()) { context.CommandTimeout = CommandTimeoutInSeconds.Value; context.p_Import_NutritionalInfo_Reset(); } }
protected override void ExecuteResetProc() { using (var context = new WoolworthsDBDataContext()) { context.CommandTimeout = CommandTimeoutInSeconds.Value; context.p_ImportHealthWellbeing_Reset(); } }
private static void updateRecipeAsFeatured(FeaturedRecipeObj featuredRecipe) { using (var context = new WoolworthsDBDataContext()) { var recipe = context.Recipes.SingleOrDefault(r => r.ID == featuredRecipe.RecipeID); if (recipe != null) { recipe.FeaturedStartDate = DateTime.Parse(featuredRecipe.STARTDATE); context.SubmitChanges(); } } }
protected override bool ExecuteDataProcessingProc() { int success; using (var db = new WoolworthsDBDataContext()) { db.CommandTimeout = CommandTimeoutInSeconds.Value; success = db.p_ImportWeeklySpecial(MasterLogId); } if (success == 0) return false; else if (success == 1) return true; else throw new ArgumentOutOfRangeException("success", "Stored Proc p_ImportWeeklySpecial returned int value that that was not equal to 1 or 0"); }
protected override bool ExecuteDataProcessingProc() { int success; using (var context = new WoolworthsDBDataContext()) { context.CommandTimeout = CommandTimeoutInSeconds.Value; success = context.p_Import_OncBpOffers_BonusPoints(MasterLogId); } if (success == 0) return false; else if (success == 1) return true; else throw new ArgumentOutOfRangeException("success", "Stored Proc p_Import_OncBpOffers_BonusPoints returned int value that that was not equal to 1 or 0"); }
// adds or returns the actual Recipe record (id) private int createRecipeRecord(RecipeObj recipe) { using (var context = new WoolworthsDBDataContext()) { var existing = context.Recipes.SingleOrDefault(r => r.ID == recipe.RecipeID); // if the recipe already exists and the action isn't to update then just return the recipe identifier if (existing != null) //Always update, regardless of action (well, it should be "i" or "u" -- && recipe.Action.ToLower() == "u") { // if the recipe exists and the instruction is to update then updates existing.CookingTime = recipe.CookingTime; existing.Description = recipe.Description; existing.Recipe1 = recipe.Recipe; existing.ImageURL = downloadRemoteImageFile(recipe.ImageURL, ImgDir, recipe.Recipe); existing.OriginImageUrl = recipe.ImageURL; existing.PrepTime = recipe.PreparationTime; existing.Serves = recipe.Serves; existing.Tip = recipe.Tip; existing.Title = recipe.Title; existing.TotalTime = recipe.TotalTime; context.SubmitChanges(); return(existing.ID); } else { // create the record regardless of whether it was an insert or update record var newRecipe = new WoolworthsDAL.Recipe { ID = recipe.RecipeID, CookingTime = recipe.CookingTime, Recipe1 = recipe.Recipe, Description = recipe.Description, ImageURL = downloadRemoteImageFile(recipe.ImageURL, ImgDir, recipe.Recipe), OriginImageUrl = recipe.ImageURL, PrepTime = recipe.PreparationTime, Serves = recipe.Serves, Tip = recipe.Tip, Title = recipe.Title, TotalTime = recipe.TotalTime }; context.Recipes.InsertOnSubmit(newRecipe); context.SubmitChanges(); return(newRecipe.ID); } } }
// work out if the cuisine already exists, if it does then use it for the mapping table, else create it private static void addCuisines(RecipeObj recipe) { using (var context = new WoolworthsDBDataContext()) { // clear the current mappings var maps = context.RecipeCuisineMaps.Where(r => r.RecipeID == recipe.RecipeID); context.RecipeCuisineMaps.DeleteAllOnSubmit(maps); context.SubmitChanges(); if (recipe.Cuisines == null) { return; } foreach (var cuisine in recipe.Cuisines) { // create or retrieve the RecipeCuisine.ID value var master = context.RecipeCuisines.SingleOrDefault(c => c.Description == cuisine.Cuisine); var recipeCuisineID = 0; if (master == null) { var toCreate = new RecipeCuisine() { Description = cuisine.Cuisine }; context.RecipeCuisines.InsertOnSubmit(toCreate); context.SubmitChanges(); recipeCuisineID = toCreate.ID; } else { recipeCuisineID = master.ID; } // add to the mapping table var map = new RecipeCuisineMap() { RecipeCuisineID = recipeCuisineID, RecipeID = recipe.RecipeID }; context.RecipeCuisineMaps.InsertOnSubmit(map); context.SubmitChanges(); } } }
protected override bool ExecuteDataProcessingProc() { int success; using (var db = new WoolworthsDBDataContext()) { db.CommandTimeout = CommandTimeoutInSeconds.Value; success = db.p_ImportTargetedOfferPEL(MasterLogId); } if (success == 0) { return(false); } if (success == 1) { return(true); } throw new ArgumentOutOfRangeException("success", "Stored Proc p_ImportTargetedOfferPEL returned int value that that was not equal to 1 or 0"); }
protected override bool ExecuteDataProcessingProc() { int success; using (var db = new WoolworthsDBDataContext()) { db.CommandTimeout = CommandTimeoutInSeconds.Value; success = db.p_ImportTargetedOffer(MasterLogId); } switch (success) { case 0: return false; case 1: return true; default: throw new ArgumentOutOfRangeException("success", "Stored Proc p_ImportTargetedOffer returned int value that that was not equal to 1 or 0"); } }
protected override bool ExecuteDataProcessingProc() { int success; using (var db = new WoolworthsDBDataContext()) { db.CommandTimeout = CommandTimeoutInSeconds.Value; success = db.p_ImportRelevantSpecial(MasterLogId); } switch (success) { case 0: return(false); case 1: return(true); default: throw new ArgumentOutOfRangeException("success", "Stored Proc p_ImportRelevantSpecial returned int value that that was not equal to 1 or 0"); } }
protected override bool ExecuteDataProcessingProc() { int success; using (var context = new WoolworthsDBDataContext()) { context.CommandTimeout = CommandTimeoutInSeconds.Value; success = context.p_Import_OnlineSellType(MasterLogId); } if (success == 0) { return(false); } else if (success == 1) { return(true); } else { throw new ArgumentOutOfRangeException("success", "Stored Proc p_Import_OnlineSellType returned int value that that was not equal to 1 or 0"); } }
protected override bool ExecuteDataProcessingProc() { int success; using (var db = new WoolworthsDBDataContext()) { db.CommandTimeout = CommandTimeoutInSeconds.Value; success = db.p_ImportProduct(MasterLogId, _imageUrlFormat, _pelImageUrlFormat); } if (success == 0) { return(false); } else if (success == 1) { return(true); } else { throw new ArgumentOutOfRangeException("success", "Stored Proc p_ImportProduct returned int value that that was not equal to 1 or 0"); } }
// clear the current list of ingredients for a given recipe and add the ones based on the file to ingest private static void addIngredients(RecipeObj recipe) { // clear the current list using (var context = new WoolworthsDBDataContext()) { var ingredToDel = context.RecipeIngredients.Where(r => r.RecipeID == recipe.RecipeID); context.RecipeIngredients.DeleteAllOnSubmit(ingredToDel); context.SubmitChanges(); } if (recipe.Ingredients == null) return; using (var context = new WoolworthsDBDataContext()) { foreach (var obj in recipe.Ingredients) { var ingred = new RecipeIngredient() { Description = obj.Ingredient, Number = obj.IngredientID, ProductArticle = obj.ProductID, RecipeID = recipe.RecipeID }; context.RecipeIngredients.InsertOnSubmit(ingred); } context.SubmitChanges(); } }
private void updateRecipeAsFeatured(FeaturedRecipeObj featuredRecipe) { using (var context = new WoolworthsDBDataContext()) { var recipe = context.Recipes.SingleOrDefault(r => r.ID == featuredRecipe.RecipeID); if (recipe == null) return; recipe.FeaturedStartDate = DateTime.Parse(featuredRecipe.STARTDATE); context.SubmitChanges(); } }
// adds or returns the actual Recipe record (id) private int createRecipeRecord(RecipeObj recipe) { using (var context = new WoolworthsDBDataContext()) { var existing = context.Recipes.SingleOrDefault(r => r.ID == recipe.RecipeID); // if the recipe already exists and the action isn't to update then just return the recipe identifier if (existing != null) //Always update, regardless of action (well, it should be "i" or "u" -- && recipe.Action.ToLower() == "u") { // if the recipe exists and the instruction is to update then updates existing.CookingTime = recipe.CookingTime; existing.Description = recipe.Description; existing.Recipe1 = recipe.Recipe; existing.ImageURL = downloadRemoteImageFile(recipe.ImageURL, ImgDir, recipe.Recipe); existing.OriginImageUrl = recipe.ImageURL; existing.PrepTime = recipe.PreparationTime; existing.Serves = recipe.Serves; existing.Tip = recipe.Tip; existing.Title = recipe.Title; existing.TotalTime = recipe.TotalTime; context.SubmitChanges(); return existing.ID; } else { // create the record regardless of whether it was an insert or update record var newRecipe = new WoolworthsDAL.Recipe { ID = recipe.RecipeID, CookingTime = recipe.CookingTime, Recipe1 = recipe.Recipe, Description = recipe.Description, ImageURL = downloadRemoteImageFile(recipe.ImageURL, ImgDir, recipe.Recipe), OriginImageUrl = recipe.ImageURL, PrepTime = recipe.PreparationTime, Serves = recipe.Serves, Tip = recipe.Tip, Title = recipe.Title, TotalTime = recipe.TotalTime }; context.Recipes.InsertOnSubmit(newRecipe); context.SubmitChanges(); return newRecipe.ID; } } }
// work out if the cuisine already exists, if it does then use it for the mapping table, else create it private void addCuisines(RecipeObj recipe) { using (var context = new WoolworthsDBDataContext()) { // clear the current mappings var maps = context.RecipeCuisineMaps.Where(r => r.RecipeID == recipe.RecipeID); context.RecipeCuisineMaps.DeleteAllOnSubmit(maps); context.SubmitChanges(); if (recipe.Cuisines == null) return; foreach (var cuisine in recipe.Cuisines) { // create or retrieve the RecipeCuisine.ID value var master = context.RecipeCuisines.SingleOrDefault(c => c.Description == cuisine.Cuisine); var recipeCuisineID = 0; if (master == null) { var toCreate = new RecipeCuisine() { Description = cuisine.Cuisine }; context.RecipeCuisines.InsertOnSubmit(toCreate); context.SubmitChanges(); recipeCuisineID = toCreate.ID; } else { recipeCuisineID = master.ID; } // add to the mapping table var map = new RecipeCuisineMap() { RecipeCuisineID = recipeCuisineID, RecipeID = recipe.RecipeID }; context.RecipeCuisineMaps.InsertOnSubmit(map); context.SubmitChanges(); } } }
// clear the current list of methods for a given recipe and add the ones based on the file to ingest private static void addMethods(RecipeObj recipe) { // clear the current list using (var context = new WoolworthsDBDataContext()) { var methodToDel = context.RecipeMethods.Where(r => r.RecipeID == recipe.RecipeID); context.RecipeMethods.DeleteAllOnSubmit(methodToDel); context.SubmitChanges(); } if (recipe.Methods == null) return; using (var context = new WoolworthsDBDataContext()) { foreach (var obj in recipe.Methods) { var method = new RecipeMethod() { Description = obj.Step, Number = obj.StepID, RecipeID = recipe.RecipeID }; context.RecipeMethods.InsertOnSubmit(method); } context.SubmitChanges(); } }