Exemple #1
0
        public ContentResult GetAllBookmarks()
        {
            BookmarkRequestStatus response = new BookmarkRequestStatus();

            try
            {
                if (Session["Bookmarks"] == null)
                {
                    response.Status     = false;
                    response.StatusType = BookmarkRequestStatus.BookmarkStatusType.Empty;
                    response.Text       = "Your list of bookmarks is empty";
                }
                else
                {
                    response.Content.Add("Bookmarks", (List <Bookmark>)Session["Bookmarks"]);
                }
            }
            catch (Exception ex)
            {
                response.Status     = false;
                response.StatusType = BookmarkRequestStatus.BookmarkStatusType.Exception;
                response.Text       = ex.Message;
            }
            return(new ContentResult
            {
                ContentType = "application/json",
                Content = response.toJson()
            });
        }
Exemple #2
0
        public ContentResult AddToBookmarks(Bookmark bookmark)
        {
            BookmarkRequestStatus response = new BookmarkRequestStatus();

            try
            {
                if (Session["Bookmarks"] == null)
                {
                    Session["Bookmarks"] = new List <Bookmark>();
                }
                if (!findBookmark(bookmark.Id))
                {
                    ((List <Bookmark>)Session["Bookmarks"]).Add(bookmark);
                }
                else
                {
                    response.Status     = false;
                    response.StatusType = BookmarkRequestStatus.BookmarkStatusType.AlreadyAdded;
                    response.Text       = "Bookmark is already added";
                }
            }
            catch (Exception ex) {
                response.Status     = false;
                response.StatusType = BookmarkRequestStatus.BookmarkStatusType.Exception;
                response.Text       = ex.Message;
            }
            response.Content.Add("RepId", bookmark);
            return(new ContentResult()
            {
                ContentType = "application/json",
                Content = response.toJson()
            });
        }