Ejemplo n.º 1
0
        public bool Insertar(Recipe_Details a)
        {
            var db = new Nu34lifeEntities();

            db.Recipe_Details.Add(a);
            db.SaveChanges();
            return(true);
        }
Ejemplo n.º 2
0
        private void SelectRecipe(Recipe_Details selectedRecipe)

        {
            try
            {
                RefreshSegments(selectedRecipe.Recipe_ID);
            }
            catch (Exception Ex)
            {
                MessageBox.Show("Error, no Item Selected\n" + Ex.Message);
            }
        }
Ejemplo n.º 3
0
        public async Task <IHttpActionResult> GetRecipe(int id_recipe)
        {
            var recipe = await db.Recipes.SingleOrDefaultAsync(x => x.Id_Recipe == id_recipe);

            var r_d = new Recipe_Details();

            r_d.Id_Recipe     = recipe.Id_Recipe;
            r_d.Name_Recipe   = recipe.Name_Recipe;
            r_d.Rate          = recipe.Rate;
            r_d.Level         = recipe.Level;
            r_d.Date_Recipe   = recipe.Date_Recipe;
            r_d.URL_Photo     = recipe.URL_Photo;
            r_d.Time          = recipe.Time;
            r_d.Number_Person = recipe.Number_Person;
            r_d.Steps         = recipe.Steps;
            r_d.Instruction   = recipe.Instruction;

            r_d.Name_User     = db.Users.Where(x => x.Id_User == recipe.Id_User).Select(x => x.Login).FirstOrDefault();
            r_d.Category_Main = db.Categories_Main.Where(x => x.Id_Category_Main == recipe.Id_Category_Main).Select(x => x.Name_Category_Main).FirstOrDefault();

            #region Categories
            List <Category_Recipe> categories = db.Categories_Recipes.Where(x => x.Id_Recipe == recipe.Id_Recipe).ToList();
            List <string>          ct         = new List <string>();
            foreach (var item in categories)
            {
                ct.Add(db.Categories.Where(x => x.Id_Category_Recipe == item.Id_Category).Select(x => x.Name_Category_Recipe).FirstOrDefault());
            }
            r_d.Categories = ct;
            #endregion
            #region Elements
            List <Element>         elements = db.Elements.Where(x => x.Id_Recipe == recipe.Id_Recipe).ToList();
            List <Element_Details> e_d      = new List <Element_Details>();

            foreach (var item in elements)
            {
                e_d.Add(new Element_Details()
                {
                    Name_Product = db.Products.Where(x => x.Id_Product == item.Id_Product).Select(x => x.Name_Product).FirstOrDefault(),
                    Quantity     = item.Quantity
                });
            }

            r_d.Elements_Details = e_d;

            #endregion
            #region Comments
            List <Comment>         comments = db.Comments.Where(x => x.Id_Recipe == recipe.Id_Recipe).ToList();
            List <Comment_Details> cd       = new List <Comment_Details>();
            foreach (var item in comments)
            {
                cd.Add(new Comment_Details()
                {
                    Name_User    = db.Users.Where(x => x.Id_User == item.Id_User).Select(x => x.Login).FirstOrDefault(),
                    Text         = item.Text,
                    Date_Comment = item.Date_Comment.ToShortDateString() + " " + item.Date_Comment.ToShortTimeString()
                });
            }
            r_d.Comments_Details = cd;
            #endregion

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

            return(Ok(r_d));
        }
Ejemplo n.º 4
0
 public bool Actualizar(Recipe_Details a)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
 public bool Actualizar(Recipe_Details a)
 {
     return(recipes_DetailsRepository.Actualizar(a));
 }
Ejemplo n.º 6
0
 public bool Insertar(Recipe_Details a)
 {
     return(recipes_DetailsRepository.Insertar(a));
 }