//convert one ingredientsInProDto to ingredientsInPro
        public static ingredientsInPro convert(ingredientsInProDto IngredientInPro)
        {
            ingredientsInPro NewIngredientInPro = new ingredientsInPro();

            NewIngredientInPro.id            = IngredientInPro.id;
            NewIngredientInPro.foodID        = IngredientInPro.foodID;
            NewIngredientInPro.ingredientsId = IngredientInPro.ingredientsId;
            NewIngredientInPro.countFor100gr = IngredientInPro.countFor100gr;
            return(NewIngredientInPro);
        }
Exemplo n.º 2
0
 // DELETE api/<controller>/5
 public IHttpActionResult Delete(ingredientsInProDto value)
 {
     if (value == null)
     {
         return(BadRequest("לא נשלח מידע"));
     }
     value = service.RemoveIngredientsInPro(value);
     if (value == null)
     {
         return(BadRequest("מחיקה נכשלה"));
     }
     return(Ok(value));
 }
Exemplo n.º 3
0
 // PUT api/<controller>/5
 public IHttpActionResult Put(ingredientsInProDto value)
 {
     if (value == null)
     {
         return(BadRequest("לא נשלח מידע"));
     }
     value = service.PostIngredientInPro(value);
     if (value == null)
     {
         return(BadRequest("עדכון נכשל"));
     }
     return(Ok(value));
 }
Exemplo n.º 4
0
 //remove ingredientInPro from database
 public ingredientsInProDto RemoveIngredientsInPro(ingredientsInProDto IngredientsInProDto)
 {
     using (HealthyMenuEntities db = new HealthyMenuEntities())
     {
         try
         {
             ingredientsInPro IngredientsInPro = db.ingredientsInProes.Remove(Convertion.IngredientsInProConvertion.convert(IngredientsInProDto));
             db.SaveChanges();
             return(Convertion.IngredientsInProConvertion.convert(IngredientsInPro));
         }
         catch
         {
             return(null);
         }
     }
 }
Exemplo n.º 5
0
 //update ingredientInPro in database
 public ingredientsInProDto PutIngredientsInPro(ingredientsInProDto IngredientsInProDto)
 {
     using (HealthyMenuEntities db = new HealthyMenuEntities())
     {
         try
         {
             ingredientsInPro IngredientsInPro = db.ingredientsInProes.FirstOrDefault(x => x.id == IngredientsInProDto.id);
             if (IngredientsInPro == null)
             {
                 return(null);
             }
             IngredientsInPro.id            = IngredientsInProDto.id;
             IngredientsInPro.foodID        = IngredientsInProDto.foodID;
             IngredientsInPro.ingredientsId = IngredientsInProDto.ingredientsId;
             IngredientsInPro.countFor100gr = IngredientsInProDto.countFor100gr;
             return(Convertion.IngredientsInProConvertion.convert(IngredientsInPro));
         }
         catch
         {
             return(null);
         }
     }
 }