Exemplo n.º 1
0
        /// <summary>
        /// Returns projects by person id
        /// </summary>
        /// <param name="personId">The person id</param>
        /// <param name="queryOperator">The query operator</param>
        /// <returns>Projects by person id</returns>
        public Task <PagedQueryResults <ParticipantTimelineDTO> > GetProjectsByPersonIdAsync(int personId, QueryableOperator <ParticipantTimelineDTO> queryOperator)
        {
            var projects = ProjectQueries.CreateGetProjectsByPersonIdQuery(this.Context, personId, queryOperator).ToPagedQueryResultsAsync(queryOperator.Start, queryOperator.Limit);

            this.logger.Trace("Retrieved projects by person id {0} and query operator {1}.", personId, queryOperator);
            return(projects);
        }
Exemplo n.º 2
0
        public void TestCreateGetProjectsByPersonIdQuery_NoProjects()
        {
            var defaultSorter = new ExpressionSorter <ParticipantTimelineDTO>(x => x.Name, SortDirection.Ascending);
            var queryOperator = new QueryableOperator <ParticipantTimelineDTO>(0, 10, defaultSorter);
            var projects      = ProjectQueries.CreateGetProjectsByPersonIdQuery(context, 1, queryOperator);

            Assert.AreEqual(0, projects.Count());
        }
Exemplo n.º 3
0
        public void TestCreateGetProjectsByPersonIdQuery_CheckRelationships()
        {
            var person = new Person
            {
                PersonId = 1
            };

            var org = new Organization
            {
                OrganizationId = 1
            };

            var program = new Program
            {
                ProgramId = 1,
                Owner     = org,
                OwnerId   = org.OrganizationId
            };

            var project = new Project
            {
                ProjectId     = 1,
                ProgramId     = program.ProgramId,
                ParentProgram = program
            };


            var participant = new Participant
            {
                ParticipantId = 1,
                Person        = person,
                PersonId      = person.PersonId,
                Project       = project,
                ProjectId     = project.ProjectId
            };

            context.Participants.Add(participant);

            var defaultSorter = new ExpressionSorter <ParticipantTimelineDTO>(x => x.Name, SortDirection.Ascending);
            var queryOperator = new QueryableOperator <ParticipantTimelineDTO>(0, 10, defaultSorter);
            var projects      = ProjectQueries.CreateGetProjectsByPersonIdQuery(context, person.PersonId, queryOperator);

            Assert.AreEqual(1, projects.Count());

            var projectResult = projects.FirstOrDefault();

            Assert.AreEqual(project.ProjectId, projectResult.ProjectId);
            Assert.AreEqual(program.ProgramId, projectResult.ProgramId);
            Assert.AreEqual(org.OrganizationId, projectResult.OfficeId);
        }
Exemplo n.º 4
0
        public void TestCreateGetProjectsByPersonIdQuery_CheckProperties()
        {
            var person = new Person
            {
                PersonId = 1
            };

            var project = new Project
            {
                ProjectId   = 1,
                Name        = "name",
                StartDate   = new DateTime(2013, 5, 1, 06, 32, 00),
                EndDate     = new DateTime(2017, 5, 1, 06, 32, 00),
                Description = "description"
            };

            var participant = new Participant
            {
                ParticipantId = 1,
                Person        = person,
                PersonId      = person.PersonId,
                Project       = project,
                ProjectId     = project.ProjectId
            };

            context.Participants.Add(participant);

            var defaultSorter = new ExpressionSorter <ParticipantTimelineDTO>(x => x.Name, SortDirection.Ascending);
            var queryOperator = new QueryableOperator <ParticipantTimelineDTO>(0, 10, defaultSorter);
            var projects      = ProjectQueries.CreateGetProjectsByPersonIdQuery(context, person.PersonId, queryOperator);

            Assert.AreEqual(1, projects.Count());

            var projectResult = projects.FirstOrDefault();

            Assert.AreEqual(project.ProjectId, projectResult.ProjectId);
            Assert.AreEqual(participant.ParticipantId, projectResult.ParticipantId);
            Assert.AreEqual(project.Name, projectResult.Name);
            Assert.AreEqual(project.StartDate, projectResult.StartDate);
            Assert.AreEqual(project.EndDate, projectResult.EndDate);
            Assert.AreEqual(project.Description, projectResult.Description);

            Assert.IsNull(projectResult.OfficeSymbol);
            Assert.IsNull(projectResult.Status);
        }
Exemplo n.º 5
0
        public void TestCreateGetProjectsByPersonIdQuery_CheckStatus()
        {
            var person = new Person
            {
                PersonId = 1
            };

            var status = new ProjectStatus
            {
                ProjectStatusId = 1,
                Status          = "status"
            };

            var project = new Project
            {
                ProjectId       = 1,
                Status          = status,
                ProjectStatusId = status.ProjectStatusId
            };


            var participant = new Participant
            {
                ParticipantId = 1,
                Person        = person,
                PersonId      = person.PersonId,
                Project       = project,
                ProjectId     = project.ProjectId
            };

            context.Participants.Add(participant);

            var defaultSorter = new ExpressionSorter <ParticipantTimelineDTO>(x => x.Name, SortDirection.Ascending);
            var queryOperator = new QueryableOperator <ParticipantTimelineDTO>(0, 10, defaultSorter);
            var projects      = ProjectQueries.CreateGetProjectsByPersonIdQuery(context, person.PersonId, queryOperator);

            Assert.AreEqual(1, projects.Count());

            var projectResult = projects.FirstOrDefault();

            Assert.AreEqual(status.Status, projectResult.Status);
        }