public CoreModels.NoteAccessRight CreateUserNote(Guid changeUserId, Guid userId, Guid noteId,
                                                         string userRights)
        {
            var user = _dbContext.Users
                       .Include(un => un.Passcode)
                       .Include(un => un.UserPhoto)
                       .First(u => u.Id == userId);
            var note = _dbContext.Notes
                       .Include((un => un.TextNote))
                       .First(n => n.Id == noteId);

            var userNote = new DbModels.UserNote(convertStrToUseRights(userRights), userId, user, noteId, note);

            _dbContext.UserNotes.Add(userNote);
            _dbContext.SaveChanges();

            return(new CoreModels.NoteAccessRight(userNote.NoteId.ToString(),
                                                  userNote.UserId.ToString(),
                                                  userRights));
        }
Beispiel #2
0
        public CoreModels.Note CreateNote(Guid userId, string name)
        {
            var note     = new DbModels.Note(name, DateTime.Now, DateTime.Now);
            var textNote = new DbModels.TextNote(note.Id, "");
            var user     = _dbContext.Users
                           .Include(u => u.Passcode)
                           .Include(u => u.UserPhoto)
                           .First(u => u.Id == userId);
            var userNote = new DbModels.UserNote(DbModels.Enums.UserRights.author,
                                                 userId, user,
                                                 note.Id,
                                                 note);

            _dbContext.Notes.Add(note);
            _dbContext.TextNotes.Add(textNote);
            _dbContext.UserNotes.Add(userNote);
            _dbContext.SaveChanges();

            return(new CoreModels.Note(note.Id.ToString(),
                                       note.Header,
                                       "author"));
        }