Exemple #1
0
        public void Initialize()
        {
            var dataGenerator = new TestDataGenerator();

            this.context = dataGenerator.GenerateContext();
            this.set     = this.context.Ingredients;
            this.service = new RecipeIngredientsService(this.set, this.context);
        }
Exemple #2
0
        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));
            }
        }
Exemple #3
0
        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));
            }
        }
Exemple #4
0
        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));
            }
        }
Exemple #5
0
        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);
        }