public async Task <JsonResult> AddNewSharedNote(SharedNoteVM noteData)
        {
            var errorMessages = noteData.VerifySharedNoteData();

            if (errorMessages.Count != 0)
            {
                return(new JsonResult(new JsonResponse {
                    Result = SharedEnums.RequestResults.Failed, Data = errorMessages
                }));
            }

            var hasCollaboration = await _collaborationService.DoesUserHasThisCollaborator(noteData.Note.UserId, noteData.SharedToId);

            switch (hasCollaboration)
            {
            case null:
                return(new JsonResult(new JsonResponse {
                    Result = SharedEnums.RequestResults.Failed, Message = "An issue happened while getting data."
                }));

            case < 1:
                return(new JsonResult(new JsonResponse {
                    Result = SharedEnums.RequestResults.Failed, Message = "Collaborator not found."
                }));
            }

            noteData.Note.IsShared = true;
            await _noteService.StartTransaction();

            var saveNoteResult = await _noteService.InsertNewNote(noteData.Note);

            if (!saveNoteResult.HasValue || saveNoteResult.Value < 1)
            {
                await _noteService.RevertTransaction();

                return(new JsonResult(new JsonResponse {
                    Result = SharedEnums.RequestResults.Failed, Message = "An issue happened while updating data."
                }));
            }

            var collaboratorTask = new CollaboratorTask {
                CollaborationId = hasCollaboration.Value,
                TaskId          = saveNoteResult.Value,
                TaskType        = nameof(Note),
                Message         = noteData.Message,
                AssignedOn      = DateTime.UtcNow,
                Permission      = (byte)noteData.Permission
            };

            var saveTaskResult = await _collaborationService.InsertNewCollaboratorTask(collaboratorTask);

            if (!saveTaskResult.HasValue || saveTaskResult.Value < 1)
            {
                await _noteService.RevertTransaction();

                return(new JsonResult(new JsonResponse {
                    Result = SharedEnums.RequestResults.Failed, Message = "An issue happened while updating data."
                }));
            }

            var noteOwner = await _userService.GetUserById(noteData.Note.UserId);

            if (noteOwner == null)
            {
                await _noteService.RevertTransaction();

                return(new JsonResult(new JsonResponse {
                    Result = SharedEnums.RequestResults.Failed, Message = "An issue happened while getting data."
                }));
            }

            var isNotified = await SendNotification(
                noteOwner,
                noteData.SharedToId,
                new UserNotification {
                Message = $"{ TokenNotifierName } has just assigned a Todo to you. Please tap to see the item.",
                Title   = "Task Assigned"
            },
                _userService
                );

            if (!isNotified)
            {
                await _noteService.RevertTransaction();

                return(new JsonResult(new JsonResponse {
                    Result = SharedEnums.RequestResults.Failed, Message = "An issue happened while updating data."
                }));
            }

            await _noteService.CommitTransaction();

            return(new JsonResult(new JsonResponse {
                Result = SharedEnums.RequestResults.Success, Data = saveNoteResult.Value
            }));
        }