Ejemplo n.º 1
0
        public bool DeleteAndInsertAll(List<Note> input, User author)
        {
            DalSmartNote.SmartNoteDal dal = new DalSmartNote.SmartNoteDal();
            bool ret = dal.DeleteAndInsertAll(input, author);

            return ret;
        }
Ejemplo n.º 2
0
        public async Task<List<Note>> GetAllNote(User input)
        {
            DalSmartNote.SmartNoteDal dal = new DalSmartNote.SmartNoteDal();
            List<Note> ret = await dal.GetAllNote(input);

            return ret;
        }
Ejemplo n.º 3
0
        public Task<List<Note>> GetAllNote(User input)
        {
            var collection = _database.GetCollection<Note>("notes");
            var filter = Builders<Note>.Filter.Eq("Author", input);
            var ret = collection.Find(filter).ToListAsync();

            return ret;
        }
Ejemplo n.º 4
0
        public bool DeleteAndInsertAll(List<Note> input, User author)
        {
            var collection = _database.GetCollection<Note>("notes");
            var filter = Builders<Note>.Filter.Eq("Author", author);
            var ret = collection.DeleteManyAsync(filter);
            collection.InsertManyAsync(input);

            return true;
        }
Ejemplo n.º 5
0
        public List<Note> GetAllNote(User input, int sortBy)
        {
            using (var db = new SQLiteContext())
            {
                List<Note> notes = null;
                switch(sortBy)
                {
                    case 0:
                        notes = db.Notes.OrderBy(n => n.Title).ToList();
                        break;
                    case 1:
                        notes = db.Notes.OrderByDescending(n => n.Title).ToList();
                        break;
                    case 2:
                        notes = db.Notes.OrderBy(n => n.Priority).ToList();
                        break;
                    case 3:
                        notes = db.Notes.OrderByDescending(n => n.Priority).ToList();
                        break;
                    case 4:
                        notes = db.Notes.OrderBy(n => n.ModoficationDate).ToList();
                        break;
                    case 5:
                        notes = db.Notes.OrderByDescending(n => n.ModoficationDate).ToList();
                        break;
                }
                foreach (var item in notes)
                {
                    item.Attachments = db.Attachments.Where(a => a.Note.Id == item.Id).ToList();
                    item.Links = db.NoteToNote.Where(n => n.OriginalNote.Id == item.Id).ToList();
                    foreach (var n in item.Links)
                    {
                        var p = n.ReferenceNote.Title;
                    }
                }

                return notes;
            }
        }
Ejemplo n.º 6
0
        public List<Note> GetNotesByParams(User user, string title, string content, DateTime? creatinDate, DateTime? modDate, int? priority, 
                                            bool? hasfile, bool? byTitle, bool? byCreationDate, bool? byModifyDate, bool? byPriority, bool? byContent)
        {
            List<Note> ret = null;
            List<Note> allNotes = GetAllNote(user, 0);
            Func<Note, bool> func = (n) => (
                                            //(n.Author.Id == user.Id) &&
                                            (byTitle.Value == true ? n.Title.Contains(title) : true) &&
                                            (hasfile.Value == true ? (n.Attachments != null && n.Attachments.Count > 0) : true) &&
                                            (byCreationDate.Value == true ? n.CreationDate.Date == creatinDate.Value.Date : true) &&
                                            (byModifyDate.Value == true ? n.ModoficationDate.Date == modDate.Value.Date : true) &&
                                            (byPriority.Value == true ? (priority.HasValue && priority == n.Priority) : true) &&
                                            (byContent.Value == true ? n.PlainText.Contains(content) : true)
                                           );

            if (allNotes != null)
            {
                ret = allNotes.Where(func).ToList();
            }

            return ret;
        }
Ejemplo n.º 7
0
 public List<Note> GetAllNote(User input, int sortBy)
 {
     return smartNoteDal.GetAllNote(input, sortBy);
 }