Exemple #1
0
        public int DeleteFavouriteGroup(int id)
        {
            int favDeleted = -1;

            try
            {
                StockDBContext sContext   = new StockDBContext();
                MyFavourite    deletedFav = sContext.MyFavouries.FirstOrDefault(f => f.MyFavouriteID == id);
                sContext.MyFavouries.Remove(deletedFav);
                favDeleted = sContext.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(favDeleted);
        }
Exemple #2
0
        // Add Fav Group to Member
        public int AddFavouriteGroup(int memberId, string favName)
        {
            MyFavourite mFav = new MyFavourite();

            mFav.MemberID        = memberId;
            mFav.MyFavouriteName = favName;
            try
            {
                StockDBContext sContext = new StockDBContext();
                sContext.MyFavouries.Add(mFav);
                sContext.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Problem with adding FavouriteGroup");
                throw ex;
            }
            return(mFav.MyFavouriteID);
        }