public IHttpActionResult PostFoodplan(Foodplan foodplan)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _collector.Foodplans.Add(foodplan);
            _collector.Save();

            return(CreatedAtRoute("DefaultApi", new { id = foodplan.FoodPlanId }, foodplan));
        }
        public IHttpActionResult GetFoodplan(int id)
        {
            Foodplan foodplan = _collector.Foodplans.GetWithId(id);

            if (foodplan == null)
            {
                return(NotFound());
            }

            var list = _collector.Foodplans.GetRecipesInFoodplan(foodplan);

            return(Ok(list));
        }
        public IHttpActionResult DeleteFoodplan(int id)
        {
            Foodplan foodplan = _collector.Foodplans.GetWithId(id);

            if (foodplan == null)
            {
                return(NotFound());
            }

            _collector.Foodplans.Delete(foodplan);
            _collector.Save();

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#4
0
        public void SetupForTests()
        {
            _testCollector = new Collector(new DatabaseContext());

            _testItem = new Item()
            {
                ItemId = 100, Name = "TestItem", IsBought = true
            };
            _testIngredient = new Ingredient()
            {
                ItemId = 101, Name = "TestIngredient", Amount = 10
            };
            _testRecipe = new Recipe()
            {
                RecipeId = 100, RecipeName = "TestOpskrift", Ingredients = new List <Ingredient>()
                {
                    _testIngredient, new Ingredient()
                }
            };
            _testFoodplan = new Foodplan()
            {
                FoodPlanId = 100, CreatedDate = DateTime.Now, RecipeList = new List <Recipe>()
                {
                    _testRecipe
                }
            };
            _testShoppinglist = new Shoppinglist()
            {
                ShoppingListId = 100, ShoppingItems = new List <Item>()
                {
                    _testItem
                }
            };
            _tesUser = new User()
            {
                UserId = 100, UserName = "******", UserPassword = "******", UserFoodplan = _testFoodplan, UserShoppinglist = _testShoppinglist
            };
        }
示例#5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="toRemove"></param>
 public void Remove(Foodplan toRemove)
 {
     throw new NotImplementedException();
 }
示例#6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="toAdd"></param>
 /// <returns></returns>
 public Task <int> Add(Foodplan toAdd)
 {
     throw new NotImplementedException();
 }