Exemple #1
0
        public GetRecipeServiceResponse GetRecipes(GetRecipeServiceRequest request)
        {
            List<Recipe> result = new List<Recipe>();

               using (var db = new MatContext())
               {
               var query = from r in db.Recipes
                           orderby r.Name
                           select r;

               var rec = (from r in db.Recipes
                           select r).First();

               Console.WriteLine("test: " +rec.Ingredients[0].Item);

               foreach(Recipe r in query){
                   Console.WriteLine(r.Ingredients);
                   result.Add(r);
               }

               }

               GetRecipeServiceResponse response = new GetRecipeServiceResponse();
               response.ID = request.ID;
               response.Result = AbstractServiceResponse.flag.SUCCESS;
               response.Recipes = result;
               return response;
        }
Exemple #2
0
        public AddRecipeServiceResponse AddRecipe(AddRecipeServiceRequest request)
        {
            if (request.Recipe == null)
                throw new ArgumentNullException();

            using (var db = new MatContext())
            {
                db.Recipes.Add(request.Recipe);
                db.SaveChanges();
            }

            AddRecipeServiceResponse response = new AddRecipeServiceResponse();
            response.ID = request.ID;
            response.Result = AddRecipeServiceResponse.flag.SUCCESS;
            return response;
        }
        public GetIngredientServiceResponse GetIngredient(GetIngredientServiceRequest request)
        {
            List<Ingredient> result = new List<Ingredient>();

            using (var db = new MatContext())
            {
            var query = from i in db.Ingredients
                        orderby i.name
                        select i;

            foreach (Ingredient i in query)
            {
                result.Add(i);
            }
            }

            GetIngredientServiceResponse response = new GetIngredientServiceResponse();
            response.ID = request.ID;
            response.Result = AbstractServiceResponse.flag.SUCCESS;
            response.Ingredients = result;
            return response;
        }