Example #1
0
        public static NextcloudNote GetNoteData(ISimpleJsonRest web, int id, NextcloudConfig config)
        {
            var result = web.Get <ApiNoteResult>("notes/" + id);

            return(new NextcloudNote(result.id, Guid.NewGuid(), config)
            {
                CreationDate = DateTime.Now,
                RemoteTimestamp = result.modified,
                Content = result.content,
                Favorite = result.favorite,
                Path = ExtractPathFromCategory(result.category),
                ModificationDate = ConvertFromEpochDate(result.modified),
                ETag = result.etag,
            });
        }
Example #2
0
 public NextcloudNote(int rid, Guid lid, NextcloudConfig cfg)
 {
     _remoteID = rid;
     _localID  = lid;
     _config   = cfg;
 }
 public NextcloudConnection(AlephLogger log, IWebProxy proxy, NextcloudConfig config)
 {
     _config = config;
     _proxy  = proxy;
     _logger = log;
 }
Example #4
0
        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),
                ModificationDate = ConvertFromEpochDate(result.modified),
                ETag             = result.etag,
            };

            if (rnote.Title.ToLower() != result.title.ToLower())
            {
                rnote.Title = result.title;
            }
            return(rnote);
        }
Example #5
0
        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),
                ETag            = result.etag,
            };

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

            if (rnote.Title.ToLower() != result.title.ToLower())
            {
                rnote.Title = result.title;
            }
            return(rnote);
        }