Ejemplo n.º 1
0
        public ActionResult <RecipesModel> Delete(int id)
        {
            RecipesModel.DeleteData(id);

            var getData = RecipesModel.Get(id);

            getData.Message = "Recipe successfully removed!";

            return(getData);
        }
Ejemplo n.º 2
0
        public ActionResult <RecipesModel> Patch(int id, [FromBody] RecipesModel.Recipe recipe)
        {
            recipe.id = id;

            RecipesModel.UpdateData(recipe);

            var getData = RecipesModel.Get(id);

            getData.Message = "Recipe successfully updated!";

            return(getData);
        }
Ejemplo n.º 3
0
        public ActionResult <RecipesModel> Post([FromBody] RecipesModel.Recipe recipe)
        {
            var getData = new RecipesModel();


            try
            {
                int newestId = RecipesModel.InsertData(recipe);
                getData         = RecipesModel.Get(newestId);
                getData.Message = "Recipe successfully created!";
            }
            catch
            {
                getData.Recipes         = null;
                getData.Message         = "Recipe creation failed!";
                getData.RequiredMessage = "title, making_time, serves, ingredients, cost";
            }
            return(getData);
        }
Ejemplo n.º 4
0
 public ActionResult <RecipesModel> Get(int id)
 {
     return(RecipesModel.Get(id));
 }