Exemplo n.º 1
0
        public void Update(RecipeWarning recipeWarnings, int id)
        {
            try
            {
                // Validar datos correctos
                bool validWarning = Validate(recipeWarnings);

                if (validWarning)
                {
                    // Que exista el id
                    bool existWord = dbContext.RecipeWarning.Any(recipeWarnings => recipeWarnings.Id == id);

                    if (existWord)
                    {
                        // actualizar
                        recipeWarnings.Id = id;


                        dbContext.Update(recipeWarnings);
                        dbContext.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
 public bool Validate(RecipeWarning recipeWarnings)
 {
     try
     {
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 3
0
        public void Delete(int id)
        {
            try
            {
                RecipeWarning recipeWarnings = dbContext.RecipeWarning.FirstOrDefault(x => x.Id == id);

                if (recipeWarnings != null)
                {
                    dbContext.Remove(recipeWarnings);
                    dbContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
        public void Create(RecipeWarning recipeWarnings)
        {
            try
            {
                bool validWarning = Validate(recipeWarnings);

                if (validWarning)
                {
                    dbContext.Add(recipeWarnings);
                    dbContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 5
0
        public IActionResult AddWarning([FromBody] RecipeWarning recipeWarning)
        {
            try
            {
                RecipeWarningCore recipeWarningCore = new RecipeWarningCore(dbContext);

                //RecipeWarning NewrecipeWarning = new RecipeWarning();


                //NewrecipeWarning.IdRecipe = IdRecipe;
                //NewrecipeWarning.IdWarning = IdWarning;

                recipeWarningCore.Create(recipeWarning);

                return(Ok("Warning Added to Recipe Succesfully"));
            }
            catch (Exception ex)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, ex));
            }
        }