public static NextcloudNote ChangeExistingNote(ISimpleJsonRest web, NextcloudNote note, NextcloudConfig config)
        {
            var data = new ApiUpdateNote {
                content = note.Content, category = CreateCategoryFromPath(note.Path)
            };
            var result = web.PutTwoWay <ApiNoteResult>(data, "notes/" + note.RemoteID);

            var rnote = new NextcloudNote(result.id, note.LocalID, config)
            {
                CreationDate    = DateTime.Now,
                RemoteTimestamp = result.modified,
                Content         = result.content,
                Favorite        = result.favorite,
                Path            = ExtractPathFromCategory(result.category),
                ETag            = result.etag,
            };

            rnote.SetModificationDate(ConvertFromEpochDate(result.modified));

            if (rnote.Title.ToLower() != result.title.ToLower())
            {
                rnote.Title = result.title;
            }
            return(rnote);
        }
Exemple #2
0
        protected override BasicHierachicalNote CreateClone()
        {
            var n = new NextcloudNote(_remoteID, _localID, _config);

            using (n.SuppressDirtyChanges())
            {
                n._content          = _content;
                n._path             = _path;
                n._creationDate     = _creationDate;
                n._modificationDate = _modificationDate;
                n._remoteTimestamp  = _remoteTimestamp;
                n._favorite         = _favorite;
                n._etag             = _etag;

                return(n);
            }
        }
        public static NextcloudNote GetNoteData(ISimpleJsonRest web, int id, NextcloudConfig config)
        {
            var result = web.Get <ApiNoteResult>("notes/" + id);

            var rnote = new NextcloudNote(result.id, Guid.NewGuid(), config)
            {
                CreationDate    = DateTime.Now,
                RemoteTimestamp = result.modified,
                Content         = result.content,
                Favorite        = result.favorite,
                Path            = ExtractPathFromCategory(result.category),
                ETag            = result.etag,
            };

            rnote.SetModificationDate(ConvertFromEpochDate(result.modified));
            return(rnote);
        }
        public static NextcloudNote UploadNewNote(ISimpleJsonRest web, NextcloudNote note, NextcloudConfig config)
        {
            var data = new ApiCreateNote {
                content = note.Content, category = CreateCategoryFromPath(note.Path)
            };
            var result = web.PostTwoWay <ApiNoteResult>(data, "notes");

            var rnote = new NextcloudNote(result.id, note.LocalID, config)
            {
                CreationDate     = DateTime.Now,
                RemoteTimestamp  = result.modified,
                Content          = result.content,
                Path             = ExtractPathFromCategory(result.category),
                ModificationDate = ConvertFromEpochDate(result.modified),
                ETag             = result.etag,
            };

            if (rnote.Title.ToLower() != result.title.ToLower())
            {
                rnote.Title = result.title;
            }
            return(rnote);
        }
 public static void DeleteNote(ISimpleJsonRest web, NextcloudNote note)
 {
     web.DeleteEmpty("notes/" + note.RemoteID);
 }