public void Initialize() { var dataGenerator = new TestDataGenerator(); this.context = dataGenerator.GenerateContext(); this.set = this.context.Ingredients; this.service = new RecipeIngredientsService(this.set, this.context); }
public HttpResponseMessage Create(RecipeIngredients model) { try { RecipeIngredientsService svc = new RecipeIngredientsService(); int res = svc.Create(model); return(Request.CreateResponse(HttpStatusCode.OK, res)); } catch (System.Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public HttpResponseMessage Delete(int id) { bool res = false; RecipeIngredientsService svc = new RecipeIngredientsService(); try { res = svc.Delete(id); return(Request.CreateResponse(HttpStatusCode.OK, res)); } catch (System.Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public HttpResponseMessage SelectAllIngredients() { List <RecipeIngredients> res = new List <RecipeIngredients>(); RecipeIngredientsService svc = new RecipeIngredientsService(); try { res = svc.SelectAll(); return(Request.CreateResponse(HttpStatusCode.OK, res)); } catch (System.Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public RecipesController() { //TODO: Decouple and refactor this.context = new NzKvoDaQmContext(); var ingredientsTypesService = new IngredientTypesService(this.context.IngredientTypes, this.context); var recipeIngredientsService = new RecipeIngredientsService(this.context.Ingredients, this.context); var recipeImagesSevice = new RecipeImagesService(this.context.RecipeImages, this.context); var recipeStepsService = new RecipeStepsService(this.context.RecipeSteps, this.context); this.recipeService = new RecipeService( this.context.Recipes, ingredientsTypesService, recipeIngredientsService, recipeImagesSevice, recipeStepsService, this.context); }