public int AddToFavourites(string type, string WebID) { member = (Member)HttpContext.Current.Session["Member"]; CommentType contentType = (CommentType)Enum.Parse(typeof(CommentType), type); Favourite favourite = new Favourite(); favourite.MemberID = member.MemberID; favourite.TheFavouriteObjectID = GetObjectID(contentType, WebID); favourite.ObjectType = (int)contentType; favourite.DTCreated = DateTime.Now; favourite.SaveWithCheck(); return 1; }
/// <summary> /// Takes an prepopulated IDataReader and creates an array of Favourites /// </summary> public static List<Favourite> PopulateObject(IDataReader dr) { ColumnFieldList list = new ColumnFieldList(dr); List<Favourite> arr = new List<Favourite>(); Favourite obj; while (dr.Read()) { obj = new Favourite(); if (list.IsColumnPresent("FavouriteID")) { obj._favouriteID = (int)dr["FavouriteID"]; } if (list.IsColumnPresent("MemberID")) { obj._memberID = (int)dr["MemberID"]; } if (list.IsColumnPresent("TheFavouriteObjectID")) { obj._theFavouriteObjectID = (int)dr["TheFavouriteObjectID"]; } if (list.IsColumnPresent("ObjectType")) { obj._objectType = (int)dr["ObjectType"]; } if (list.IsColumnPresent("DTCreated")) { obj._dTCreated = (DateTime)dr["DTCreated"]; } arr.Add(obj); } dr.Close(); return arr; }
private static void MarkAsFovorite(data.Comment comment) { Debug.Assert(comment != null, "comment != null"); switch (comment.CommentType) { case 1: case 2: { var favorite = new Favourite() { MemberID = comment.MemberIDFrom, TheFavouriteObjectID = comment.ObjectID, ObjectType = comment.CommentType, DTCreated = DateTime.Now }; favorite.SaveWithCheck(); break; } } }