/// <summary>
        /// Creates a new Note.
        /// </summary>
        /// <param name="entityToCreate">Note domain object with the properties to map to an Notes table entity</param>
        public void Create(Note entityToCreate)
        {
            // get the last inserted Note ordering index
            var maxOrderingIndex = -1;
            var result = _unitOfWork.Load<NoteEntity>("Notes", n => n.PartitionKey == entityToCreate.Owner.RowKey).ToList();

            if (result.Any())
            {
                maxOrderingIndex = result.Max(n => n.OrderingIndex);
            }

            entityToCreate.PartitionKey = entityToCreate.Owner.RowKey;
            entityToCreate.RowKey = ShortGuid.NewGuid();
            entityToCreate.OrderingIndex = maxOrderingIndex + 1;
            entityToCreate.ContainerKeys = string.Format("{0}+{1}", entityToCreate.Container.PartitionKey, entityToCreate.Container.RowKey);

            var noteEntity = entityToCreate.MapToNoteEntity();
            _unitOfWork.Create(noteEntity, "Notes");

            // the User that creates the new Note is automatically add in the Note Shares list.
            var noteSharePartitionKey = string.Format("{0}+{1}", entityToCreate.PartitionKey, entityToCreate.RowKey);
            var noteShare = new NoteShareEntity(noteSharePartitionKey, entityToCreate.Owner.RowKey);
            _unitOfWork.Create(noteShare, "NoteShares");

            // store in the TaskListNotes an entity to indicate that the Note is in the containing TaskList.
            var taskListNoteEntityPartitionKey = string.Format("{0}+{1}", entityToCreate.Container.PartitionKey, entityToCreate.Container.RowKey);
            var taskListNoteEntityRowKey = string.Format("{0}+{1}", entityToCreate.PartitionKey, entityToCreate.RowKey);
            var taskListNoteEntity = new TaskListNoteEntity(taskListNoteEntityPartitionKey, taskListNoteEntityRowKey);
            _unitOfWork.Create(taskListNoteEntity, "TaskListNotes");
        }
        public void Create(Note entityToCreate)
        {
            var note = entityToCreate.MapToNoteEntity();
            var maxIndex = _notes.Max(n => n.OrderingIndex);
            note.OrderingIndex = maxIndex + 1;
            var noteShare = new NoteShareEntity(entityToCreate.RowKey, entityToCreate.Owner.RowKey);

            _notes.Add(note);
            _noteShares.Add(noteShare);
        }
 /// <summary>
 /// Updates an entity in the Notes Azure Table.
 /// </summary>
 /// <param name="entityToUpdate">Note domain object with the properties to update an existing Notes table entity</param>
 public void Update(Note entityToUpdate)
 {
     _unitOfWork.Update("Notes", entityToUpdate.MapToNoteEntity());
 }
        public void Update(Note entityToUpdate)
        {
            var note = entityToUpdate.MapToNoteEntity();
            var noteToRemove = _notes.First(n => n.PartitionKey == note.PartitionKey && n.RowKey == note.RowKey);

            _notes.Remove(noteToRemove);
            _notes.Add(note);
        }