public IActionResult GetAllTasksForUserByProject(string UserId, int projId) { try { return(Ok(taskOrchestrator.GetUserProjectTasks(UserId, projId))); } catch (Exception ex) { _logger.LogError(ex, $"Error during GET Tasks by User Id - {UserId} by Project Id - {projId}"); return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public IHttpActionResult GetAllTasksForUserByProject(string UserId, int projId) { try { return(Ok(taskLogic.GetUserProjectTasks(UserId, projId))); } catch (Exception ex) { _logger.LogError(ex, $"Error during GET Tasks by User Id - {UserId} by Project Id - {projId}"); return(InternalServerError(ex)); } }
public void Test_For_GetUserProjectTasks() { // Arrange Guid testUserGuid = Guid.NewGuid(); int testProjectId = 10; var tasksList = new Models.ViewModels.Task[] { new Models.ViewModels.Task() { ProjectId = 10, ProjectName = "TestProject-10", TaskOwnerId = testUserGuid, Priority = 10, TaskId = 10, TaskName = "TestTask1" }, new Models.ViewModels.Task() { ProjectId = 2, ProjectName = "TestProject-2", TaskOwnerId = Guid.NewGuid(), Priority = 5, TaskId = 11, TaskName = "TestTask2" }, new Models.ViewModels.Task() { ProjectId = 10, ProjectName = "TestProject-10", TaskOwnerId = testUserGuid, Priority = 15, TaskId = 9, TaskName = "TestTask3" }, new Models.ViewModels.Task() { ProjectId = 4, ProjectName = "TestProject-4", TaskOwnerId = Guid.NewGuid(), Priority = 20, TaskId = 7, TaskName = "TestTask4" }, new Models.ViewModels.Task() { ProjectId = 5, ProjectName = "TestProject-5", TaskOwnerId = testUserGuid, Priority = 30, TaskId = 5, TaskName = "TestTask5", ParentTaskName = "TestParentTask1", ParentTaskId = 200 }, new Models.ViewModels.Task() { ProjectId = 10, ProjectName = "TestProject-10", TaskOwnerId = testUserGuid, Priority = 30, TaskId = 5, TaskName = "TestTask6", ParentTaskName = "TestParentTask1", ParentTaskId = 200 }, new Models.ViewModels.Task() { ProjectId = 5, ProjectName = "TestProject-5", TaskOwnerId = testUserGuid, Priority = 30, TaskId = 5, TaskName = "TestTask7", ParentTaskName = "TestParentTask2", ParentTaskId = 202 }, }.AsEnumerable(); IEnumerable <Models.ViewModels.Task> expectedResult; expectedResult = tasksList.Where(p => p.TaskOwnerId == testUserGuid && p.ProjectId == testProjectId); mockTaskRepo.Setup(repo => repo.Search(It.IsAny <System.Linq.Expressions.Expression <Func <Models.DataModels.Task, bool> > >())).Returns(expectedResult.AsDataModel()); // Act var actualResult = tasksLogicTest.GetUserProjectTasks("TestUser1", testProjectId); // Assert Assert.Equal(expectedResult.Count(), actualResult.Count()); }