Exemplo n.º 1
0
        public static BookmarkDO BookmarkTableRowToDO(DataRow row)
        {
            BookmarkDO bookmarkDO = new BookmarkDO();

            bookmarkDO.BookmarkID = int.Parse(row["BookmarkID"].ToString());
            bookmarkDO.UserID     = int.Parse(row["UserID"].ToString());
            bookmarkDO.ReactorID  = int.Parse(row["ReactorID"].ToString());
            return(bookmarkDO);
        }
Exemplo n.º 2
0
        public static BookmarkDO BookmarkPOtoDO(BookmarkPO from)
        {
            BookmarkDO to = new BookmarkDO();

            to.BookmarkID = from.BookmarkID;
            to.UserID     = from.UserID;
            to.ReactorID  = from.ReactorID;
            return(to);
        }
        public List <BookmarkDO> ObtainBookmarksByUserID(int userID)
        {
            _logger.LogMessage("Info", "Obtain Bookmarks called", MethodBase.GetCurrentMethod().ToString(),
                               "Request to obtain bookmarks for user with ID #" + userID + " received.");
            List <BookmarkDO> bookmarkList        = new List <BookmarkDO>();
            SqlConnection     connectionToSql     = null;
            SqlCommand        obtainUserBookmarks = null;
            SqlDataAdapter    adapter             = null;
            DataTable         bookmarkTable       = new DataTable();

            try
            {
                connectionToSql                 = new SqlConnection(_connectionString);
                obtainUserBookmarks             = new SqlCommand("OBTAIN_USER_BOOKMARKS", connectionToSql);
                obtainUserBookmarks.CommandType = CommandType.StoredProcedure;
                obtainUserBookmarks.Parameters.AddWithValue("@UserID", userID);

                connectionToSql.Open();
                adapter = new SqlDataAdapter(obtainUserBookmarks);
                adapter.Fill(bookmarkTable);

                foreach (DataRow row in bookmarkTable.Rows)
                {
                    BookmarkDO bookmarkDO = Mapping.Mapper.BookmarkTableRowToDO(row);
                    bookmarkList.Add(bookmarkDO);
                }

                if (bookmarkList.Count > 0)
                {
                    _logger.LogMessage("BookmarkDO list obtained.");
                }
                else
                {
                    _logger.LogMessage("No bookmarks found.");
                }
            }
            catch (Exception ex)
            {
                _logger.LogMessage(ex, "Fatal");
                throw ex;
            }
            finally
            {
                if (connectionToSql != null)
                {
                    connectionToSql.Close();
                    connectionToSql.Dispose();
                }
                if (adapter != null)
                {
                    adapter.Dispose();
                }
            }
            return(bookmarkList);
        }