Ejemplo n.º 1
0
        /// <summary>
        /// Get bookmarks asyncronously
        /// </summary>
        /// <param name="queryOperator">The query operator to apply</param>
        /// <returns>List of bookmarks</returns>
        public Task <PagedQueryResults <BookmarkDTO> > GetBookmarksAsync(QueryableOperator <BookmarkDTO> queryOperator)
        {
            var query = BookmarkQueries.CreateGetBookmarksQuery(Context);

            query = query.Apply(queryOperator);
            return(query.ToPagedQueryResultsAsync(queryOperator.Start, queryOperator.Limit));
        }
Ejemplo n.º 2
0
        public void TestCreateGetBookmarksQuery_Organization()
        {
            var organizationType = new OrganizationType
            {
                OrganizationTypeId   = OrganizationType.Other.Id,
                OrganizationTypeName = OrganizationType.Other.Value
            };

            var organization = new Organization
            {
                OrganizationId     = 1,
                OrganizationType   = organizationType,
                OrganizationTypeId = organizationType.OrganizationTypeId,
                Name   = "name",
                Status = "status"
            };

            var bookmark = new Bookmark
            {
                BookmarkId     = 1,
                OrganizationId = organization.OrganizationId,
                Organization   = organization,
                PrincipalId    = 1,
                AddedOn        = DateTimeOffset.Now,
                Automatic      = false
            };

            context.OrganizationTypes.Add(organizationType);
            context.Organizations.Add(organization);
            context.Bookmarks.Add(bookmark);

            var bookmarks   = BookmarkQueries.CreateGetBookmarksQuery(context);
            var firstResult = bookmarks.First();

            Assert.AreEqual(bookmark.BookmarkId, firstResult.BookmarkId);
            Assert.AreEqual(bookmark.OrganizationId, firstResult.OrganizationId);
            Assert.AreEqual(bookmark.PrincipalId, firstResult.PrincipalId);
            Assert.AreEqual(bookmark.Automatic, firstResult.Automatic);
            bookmark.AddedOn.Should().BeCloseTo(DateTimeOffset.Now, 3000);
            Assert.AreEqual("Organization", firstResult.Type);
            Assert.AreEqual(organization.Status, firstResult.OfficeSymbolOrStatus);
            Assert.AreEqual(organization.Name, firstResult.Name);
        }
Ejemplo n.º 3
0
        public void TestCreateGetBookmarksQuery_Office()
        {
            var organizationType = new OrganizationType
            {
                OrganizationTypeId   = OrganizationType.Office.Id,
                OrganizationTypeName = OrganizationType.Office.Value
            };

            var office = new Organization
            {
                OrganizationId     = 1,
                OrganizationTypeId = organizationType.OrganizationTypeId,
                OfficeSymbol       = "officeSymbol",
                Name = "name"
            };
            var now      = DateTimeOffset.Now;
            var bookmark = new Bookmark
            {
                BookmarkId  = 1,
                OfficeId    = office.OrganizationId,
                Office      = office,
                PrincipalId = 1,
                AddedOn     = now,
                Automatic   = false
            };

            context.OrganizationTypes.Add(organizationType);
            context.Organizations.Add(office);
            context.Bookmarks.Add(bookmark);

            var bookmarks   = BookmarkQueries.CreateGetBookmarksQuery(context);
            var firstResult = bookmarks.First();

            Assert.AreEqual(bookmark.BookmarkId, firstResult.BookmarkId);
            Assert.AreEqual(bookmark.OfficeId, firstResult.OfficeId);
            Assert.AreEqual(bookmark.PrincipalId, firstResult.PrincipalId);
            Assert.AreEqual(bookmark.Automatic, firstResult.Automatic);
            Assert.AreEqual(now, bookmark.AddedOn);
            Assert.AreEqual("Office", firstResult.Type);
            Assert.AreEqual(office.OfficeSymbol, firstResult.OfficeSymbolOrStatus);
            Assert.AreEqual(office.Name, firstResult.Name);
        }
Ejemplo n.º 4
0
        public void TestCreateGetBookmarksQuery_Program()
        {
            var active = new ProgramStatus
            {
                ProgramStatusId = ProgramStatus.Active.Id,
                Status          = ProgramStatus.Active.Value
            };

            var organizationType = new OrganizationType
            {
                OrganizationTypeId   = OrganizationType.Office.Id,
                OrganizationTypeName = OrganizationType.Office.Value
            };

            var owner1 = new Organization
            {
                OrganizationId     = 1,
                OrganizationTypeId = organizationType.OrganizationTypeId,
                Name         = "owner 1",
                OfficeSymbol = "owner 1 symbol",
            };

            var program1 = new Program
            {
                ProgramId   = 1,
                Description = "desc1",
                History     = new History
                {
                    CreatedBy = 1,
                },
                Name            = "program 1",
                Owner           = owner1,
                OwnerId         = owner1.OrganizationId,
                ProgramStatus   = active,
                ProgramStatusId = active.ProgramStatusId,
            };

            var bookmark = new Bookmark
            {
                BookmarkId  = 1,
                ProgramId   = program1.ProgramId,
                Program     = program1,
                PrincipalId = 1,
                AddedOn     = DateTimeOffset.Now,
                Automatic   = false
            };

            context.OrganizationTypes.Add(organizationType);
            context.Programs.Add(program1);
            context.Organizations.Add(owner1);
            context.ProgramStatuses.Add(active);
            context.Bookmarks.Add(bookmark);

            var bookmarks   = BookmarkQueries.CreateGetBookmarksQuery(context);
            var firstResult = bookmarks.First();

            Assert.AreEqual(bookmark.BookmarkId, firstResult.BookmarkId);
            Assert.AreEqual(bookmark.ProgramId, firstResult.ProgramId);
            Assert.AreEqual(bookmark.PrincipalId, firstResult.PrincipalId);
            Assert.AreEqual(bookmark.Automatic, firstResult.Automatic);
            bookmark.AddedOn.Should().BeCloseTo(DateTimeOffset.Now, 3000);
            Assert.AreEqual("Program", firstResult.Type);
            Assert.AreEqual(owner1.OfficeSymbol, firstResult.OfficeSymbolOrStatus);
            Assert.AreEqual(program1.Name, firstResult.Name);
        }
Ejemplo n.º 5
0
        public void TestCreateGetBookmarksQuery_Person()
        {
            var status = new ParticipantStatus {
                ParticipantStatusId = 1,
                Status = "status"
            };

            var participation = new Participant
            {
                ParticipantId       = 1,
                ParticipantStatusId = status.ParticipantStatusId,
                Status = status
            };
            var person = new Person
            {
                PersonId   = 1,
                Alias      = "alias",
                FamilyName = "family",
                FirstName  = "firstName",
                GivenName  = "givenName",
                LastName   = "lastName",
                MiddleName = "middleName",
                NamePrefix = "Mr.",
                NameSuffix = "III",
                Patronym   = "patronym",
                FullName   = "full name",
                Gender     = new Gender
                {
                    GenderId   = Gender.Female.Id,
                    GenderName = Gender.Female.Value
                }
            };

            person.Participations.Add(participation);

            var bookmark = new Bookmark
            {
                BookmarkId  = 1,
                PersonId    = person.PersonId,
                Person      = person,
                PrincipalId = 1,
                AddedOn     = DateTimeOffset.Now,
                Automatic   = false
            };

            context.ParticipantStatuses.Add(status);
            context.Participants.Add(participation);
            context.People.Add(person);
            context.Bookmarks.Add(bookmark);

            var bookmarks   = BookmarkQueries.CreateGetBookmarksQuery(context);
            var firstResult = bookmarks.First();

            Assert.AreEqual(bookmark.BookmarkId, firstResult.BookmarkId);
            Assert.AreEqual(bookmark.PersonId, firstResult.PersonId);
            Assert.AreEqual(bookmark.PrincipalId, firstResult.PrincipalId);
            Assert.AreEqual(bookmark.Automatic, firstResult.Automatic);
            bookmark.AddedOn.Should().BeCloseTo(DateTimeOffset.Now, 3000);
            Assert.AreEqual("Person", firstResult.Type);
            Assert.AreEqual(status.Status, firstResult.OfficeSymbolOrStatus);
            Assert.AreEqual(person.FullName, firstResult.Name);
        }