示例#1
0
        public Guid Replace(BookmarkReplaceModel model)
        {
            BookmarkRequestModel bookmarkRequest =
                Find(new BookmarkFindModel
            {
                UserId    = model.UserId,
                DocId     = model.DocId,
                View      = model.View,
                Page      = model.Page,
                ScrollPos = model.ScrollPos,
                FolderId  = model.FolderId
            });

            Remove(new BookmarkRemoveModel {
                Id = bookmarkRequest.Id
            });

            Guid newBmId =
                Add(new BookmarkAddModel
            {
                DocId     = model.DocId,
                FolderId  = model.FolderId,
                Page      = model.Page,
                ScrollPos = model.ScrollPos,
                TopicName = model.TopicName,
                UserId    = model.UserId,
                View      = model.View
            });

            return(newBmId);
        }
        public IHttpActionResult CreateBookmark(BookmarkRequestModel model)
        {
            var userId = this.User.Identity.GetUserId();

            if (!ModelState.IsValid || model == null)
            {
                return(BadRequest("Bookmark not added"));
            }

            if (bookmarkService.Exist(model.Url, userId))
            {
                return(BadRequest("Bookmark already added"));
            }

            var tags    = Mapper.Map <IEnumerable <TagRequestModel>, IEnumerable <Tag> >(model.Tags);
            var website = Mapper.Map <Website>(model.Website);

            bookmarkService.Add(model.Title, model.Url, model.Description, model.SnapshotBase64String, tags, website, userId);

            return(Ok("bookmark added"));
        }