/// <summary> /// Returns the last open board for a user /// </summary> /// <param name="projectId">Project Id</param> /// <param name="userId">User Id</param> /// <returns>Id of the last board the user opened</returns> public async Task <string> GetLastOpenBoardForUser(string projectId, string userId) { UserTaskBoardHistory userTaskBoardHistory = await _UserTaskBoardHistoryCollection.Find(u => u.ProjectId == projectId && u.UserId == userId).FirstOrDefaultAsync(); if (userTaskBoardHistory == null) { return(string.Empty); } return(userTaskBoardHistory.LastOpenBoardId); }
/// <summary> /// Returns the last open board for a user /// </summary> /// <param name="projectId">Project Id</param> /// <param name="userId">User Id</param> /// <param name="boardId">Board Id</param> /// <returns>Id of the last board the user opened</returns> public async Task SetLastOpenBoardForUser(string projectId, string userId, string boardId) { UserTaskBoardHistory userTaskBoardHistory = await _UserTaskBoardHistoryCollection.Find(u => u.ProjectId == projectId && u.UserId == userId).FirstOrDefaultAsync(); if (userTaskBoardHistory == null) { userTaskBoardHistory = new UserTaskBoardHistory(); userTaskBoardHistory.Id = Guid.NewGuid().ToString(); userTaskBoardHistory.UserId = userId; userTaskBoardHistory.ProjectId = projectId; userTaskBoardHistory.LastOpenBoardId = boardId; await _UserTaskBoardHistoryCollection.InsertOneAsync(userTaskBoardHistory); } else { userTaskBoardHistory.LastOpenBoardId = boardId; await _UserTaskBoardHistoryCollection.ReplaceOneAsync(u => u.Id == userTaskBoardHistory.Id, userTaskBoardHistory); } }