示例#1
0
        //(方法)將喜歡的食譜+進收藏夾
        private void likeintoColn(int RecipeID, string FolderName, int Mid)
        {
            var q  = (this.dbcontext.CollectionFolder_Table.Where(m => m.MemberID == Mid && m.CollectionFolder == FolderName).Select(m => m.CollectionFolderID)).FirstOrDefault();
            int id = Convert.ToInt32(q);
            Collection_Table _collection = new Collection_Table()
            {
                CollectionFolderID = id,
                ReicipeID          = RecipeID,
                Datetime           = DateTime.Now
            };

            dbcontext.Collection_Table.Add(_collection);
            dbcontext.SaveChanges();
            MessageBox.Show("成功加入收藏夾");
            Close();
        }
示例#2
0
        //(方法)將此頁的食譜加入收藏
        private void Addintocoln(int rpid)
        {
            var countsame = this.Delicious.Collection_Table.Where(m => m.CollectionFolder_Table.MemberID == memberData.MemberID && m.ReicipeID == rpid).Count();

            if (countsame > 0)
            {
                MessageBox.Show("已加入收藏過");
                btn_Favorites.Enabled = false;
            }
            else
            {
                var q = this.Delicious.CollectionFolder_Table.Where(m => m.MemberID == memberData.MemberID && m.CollectionFolder == "我的最愛").Select(m => m.CollectionFolderID).FirstOrDefault();
                Collection_Table coln_table = new Collection_Table()
                {
                    CollectionFolderID = q,
                    ReicipeID          = rpid,
                    Datetime           = DateTime.Now
                };
                this.Delicious.Collection_Table.Add(coln_table);
                this.Delicious.SaveChanges();
                MessageBox.Show("成功加入我的收藏");
            }
            btn_Favorites.ForeColor = Color.Yellow;
        }