public void TestCreateGetSimplePersonDTOsQuery_DoesNotHavePlaceOfBirth() { var person = new Person { FullName = "fullname", Gender = new Gender { GenderId = Gender.Female.Id, GenderName = Gender.Female.Value } }; var status = new ParticipantStatus { ParticipantStatusId = 1, Status = "status" }; var participant = new Participant { Status = status, Person = person, }; context.ParticipantStatuses.Add(status); person.Participations.Add(participant); context.People.Add(person); context.Genders.Add(person.Gender); var result = PersonQueries.CreateGetSimplePersonDTOsQuery(context).First(); Assert.IsNull(result.CityOfBirthId); Assert.IsNull(result.CityOfBirth); }
public void TestCreateGetSimplePersonDTOsQuery_CurrentParticipation_StatusIsNull() { var person = new Person { Alias = "alias", FamilyName = "family", FirstName = "firstName", GivenName = "givenName", LastName = "lastName", MiddleName = "middleName", NamePrefix = "Mr.", NameSuffix = "III", Patronym = "patronym", Gender = new Gender { GenderId = Gender.Female.Id, GenderName = Gender.Female.Value } }; var participant = new Participant { Person = person, }; person.Participations.Add(participant); context.People.Add(person); context.Genders.Add(person.Gender); var result = PersonQueries.CreateGetSimplePersonDTOsQuery(context).First(); Assert.AreEqual(PersonQueries.UNKNOWN_PARTICIPANT_STATUS, result.CurrentStatus); }
public void TestCreateGetSimplePersonDTOsQuery_CheckDateOfBirth() { var person = new Person { DateOfBirth = DateTime.UtcNow, IsDateOfBirthEstimated = true, FullName = "fullname", Gender = new Gender { GenderId = Gender.Female.Id, GenderName = Gender.Female.Value } }; var status = new ParticipantStatus { ParticipantStatusId = 1, Status = "status" }; var participant = new Participant { Status = status, Person = person, }; context.ParticipantStatuses.Add(status); person.Participations.Add(participant); context.People.Add(person); context.Genders.Add(person.Gender); var result = PersonQueries.CreateGetSimplePersonDTOsQuery(context).First(); Assert.AreEqual(person.DateOfBirth, result.DateOfBirth); Assert.AreEqual(person.IsDateOfBirthEstimated, result.IsDateOfBirthEstimated); }
public void TestCreateGetSimplePersonDTOsQuery_PlaceOfBirthIsUnknown() { var person = new Person { FullName = "fullname", Gender = new Gender { GenderId = Gender.Female.Id, GenderName = Gender.Female.Value }, IsPlaceOfBirthUnknown = true }; var status = new ParticipantStatus { ParticipantStatusId = 1, Status = "status" }; var participant = new Participant { Status = status, Person = person, }; context.ParticipantStatuses.Add(status); person.Participations.Add(participant); context.People.Add(person); context.Genders.Add(person.Gender); var result = PersonQueries.CreateGetSimplePersonDTOsQuery(context).First(); Assert.AreEqual(result.IsPlaceOfBirthUnknown, result.IsPlaceOfBirthUnknown); }
/// <summary> /// Returns education and professional employment information for a user asyncronously /// </summary> /// <param name="personId">The person id to lookup</param> /// <returns>Education and professional employment information for person</returns> public async Task <IList <EducationEmploymentDTO> > GetEmploymentsByPersonIdAsync(int personId) { var employments = await PersonQueries.CreateGetEmploymentsByPersonIdQuery(this.Context, personId).ToListAsync(); this.logger.Trace("Retrieved employments for person info by id {0}.", personId); return(employments); }
/// <summary> /// Returns professional employments information for a user /// </summary> /// <param name="personId">The person id to lookup</param> /// <returns>Professional employments information for person</returns> public IList <EducationEmploymentDTO> GetEducationsByPersonId(int personId) { var educations = PersonQueries.CreateGetEducationsByPersonIdQuery(this.Context, personId).ToList(); this.logger.Trace("Retrieved educations for person info by id {0}.", personId); return(educations); }
/// <summary> /// Returns contact info related to a person asyncronously /// </summary> /// <param name="personId">The person id to lookup</param> /// <returns>Contact info related to person</returns> public Task <ContactInfoDTO> GetContactInfoByIdAsync(int personId) { var contactInfo = PersonQueries.CreateGetContactInfoByIdQuery(this.Context, personId).SingleOrDefaultAsync(); this.logger.Trace("Retrieved contact info by id {0}.", personId); return(contactInfo); }
/// <summary> /// Returns general information for a user asyncronously /// </summary> /// <param name="personId">The person id to lookup</param> /// <returns>Personally identifiable information for person</returns> public Task <GeneralDTO> GetGeneralByIdAsync(int personId) { var general = PersonQueries.CreateGetGeneralByIdQuery(this.Context, personId).SingleOrDefaultAsync(); this.logger.Trace("Retrieved general person info by id {0}.", personId); return(general); }
private string GetPlayerName(int idPerson) { using (var context = new FcDeHoekContext()) { var player = PersonQueries.GetById(context, idPerson); return(player == null ? string.Empty : $"{player.Name} {player.FirstName}"); } }
public void TestCreateGetSimplePersonDTOsQuery_CheckPlaceOfBirth() { var country = new Location { LocationName = "country", LocationId = 1 }; var division = new Location { LocationName = "division", LocationId = 2 }; var city = new Location { LocationName = "city", LocationId = 3, Division = division, DivisionId = division.LocationId, Country = country, CountryId = country.LocationId }; var person = new Person { FullName = "fullname", Gender = new Gender { GenderId = Gender.Female.Id, GenderName = Gender.Female.Value }, PlaceOfBirth = city, PlaceOfBirthId = city.LocationId }; var status = new ParticipantStatus { ParticipantStatusId = 1, Status = "status" }; var participant = new Participant { Status = status, Person = person, }; context.Locations.Add(city); context.Locations.Add(division); context.Locations.Add(country); context.ParticipantStatuses.Add(status); person.Participations.Add(participant); context.People.Add(person); context.Genders.Add(person.Gender); var result = PersonQueries.CreateGetSimplePersonDTOsQuery(context).First(); Assert.AreEqual(city.LocationId, result.CityOfBirthId); Assert.AreEqual(city.LocationName, result.CityOfBirth); Assert.AreEqual(division.LocationName, result.DivisionOfBirth); Assert.AreEqual(country.LocationName, result.CountryOfBirth); }
public async Task GetAllAsync_Uses_Map_From_IMapper() { // Arrange var sut = new PersonQueries(_PersonRepository.Object, _mapper.Object); // Act await sut.Search(It.IsAny <string>()); // Assert _mapper.Verify(m => m.Map <IEnumerable <PersonDto> >(It.IsAny <IEnumerable <Person> >()), Times.Once); }
public void GetPersonsBetweenBirthDates_PersonBornOnThatDay_ReturnsThatPersonInTheList() { var bDate = RandomUtil.GetRandomDateInThePast(1); var person = CreatePerson(RandomUtil.GetRandomString(), RandomUtil.GetRandomString(), bDate); var persons = PersonQueries.GetPersonsBetweenBirthDates(Context, bDate); Assert.IsNotEmpty(persons); Assert.IsTrue(persons.Contains(person)); }
public async Task GetAllAsync_Uses_Search_From_IPersonRepository() { // Arrange var sut = new PersonQueries(_PersonRepository.Object, _mapper.Object); // Act await sut.Search(It.IsAny <string>()); // Assert _PersonRepository.Verify(r => r.Search(It.IsAny <string>()), Times.Once); }
/// <summary> /// Gets a list of bookmark dtos /// </summary> /// <param name="context">The context to query</param> /// <returns>Bookmark dtos</returns> public static IQueryable <BookmarkDTO> CreateGetBookmarksQuery(EcaContext context) { Contract.Requires(context != null, "The context must not be null."); var allPeople = PersonQueries.CreateGetSimplePersonDTOsQuery(context); var query = from bookmark in context.Bookmarks let hasOffice = bookmark.OfficeId.HasValue let office = bookmark.Office let hasProgram = bookmark.ProgramId.HasValue let program = bookmark.Program let hasProject = bookmark.ProjectId.HasValue let project = bookmark.Project let hasPerson = bookmark.PersonId.HasValue let person = allPeople.Where(x => x.PersonId == bookmark.PersonId).FirstOrDefault() let hasOrganization = bookmark.OrganizationId.HasValue let organization = bookmark.Organization let ownerSymbol = hasProject ? project.ParentProgram.Owner.OfficeSymbol : hasProgram ? program.Owner.OfficeSymbol : hasOffice ? office.OfficeSymbol : "UNKNOWN OFFICE SYMBOL" let orgRoleFundingSource = hasOrganization ? bookmark.Organization.OrganizationRoles.Where(x => x.OrganizationRoleId == OrganizationRole.FundingSource.Id).FirstOrDefault() : null select new BookmarkDTO { BookmarkId = bookmark.BookmarkId, OfficeId = bookmark.OfficeId, ProgramId = bookmark.ProgramId, ProjectId = bookmark.ProjectId, PersonId = bookmark.PersonId, OrganizationId = bookmark.OrganizationId, PrincipalId = bookmark.PrincipalId, AddedOn = bookmark.AddedOn, Automatic = bookmark.Automatic, Type = hasProject ? "Project" : hasOffice ? "Office" : hasProgram ? "Program" : hasPerson ? "Person" : hasOrganization ? ((orgRoleFundingSource != null) ? "Funding" : "Organization") : "Unknown", OfficeSymbolOrStatus = (hasProject || hasProgram || hasOffice) ? ownerSymbol : hasPerson ? person.CurrentStatus : hasOrganization ? organization.Status : "", Name = hasProject ? project.Name : hasOffice ? office.Name : hasProgram ? program.Name : hasPerson ? person.FullName : hasOrganization ? organization.Name : "" }; return(query); }
public void GetPersonByParthOfName_ReturnsListOfPersons_withExpectedLastName() { var lastName = RandomUtil.GetRandomString(15); CreatePerson(RandomUtil.GetRandomString(), lastName); var persons = PersonQueries.GetPersonsByParthOfName(Context, lastName.Substring(8)); Assert.IsNotNull(persons); Assert.IsNotNull(persons.Where(p => p.LastName == lastName)); }
public void TestCreateGetRelatedPersonByDependentFamilyMemberQuery_CheckProperties() { var spousePersonType = new DependentType { DependentTypeId = DependentType.Spouse.Id }; var gender = new Gender { GenderId = Gender.Female.Id, GenderName = Gender.Female.Value }; var person = new Person { PersonId = 10, GenderId = gender.GenderId, Gender = gender }; var dependent = new PersonDependent { DependentTypeId = spousePersonType.DependentTypeId, DependentId = 2, PersonId = person.PersonId, FirstName = "firstName", LastName = "lastName", NameSuffix = "III", GenderId = gender.GenderId, Person = person }; var status = new ParticipantStatus { ParticipantStatusId = 1, Status = "status" }; var participant = new Participant { Status = status, Person = person, }; context.ParticipantStatuses.Add(status); person.Participations.Add(participant); person.Family.Add(dependent); context.People.Add(person); context.PersonDependents.Add(dependent); context.DependentTypes.Add(spousePersonType); var result = PersonQueries.CreateGetRelatedPersonByDependentFamilyMemberQuery(context, dependent.DependentId).FirstOrDefault(); Assert.IsNotNull(result); Assert.AreEqual(person.PersonId, result.PersonId); }
private List <PersonModel> GetStaff() { using (var context = new FcDeHoekContext()) { var models = new List <PersonModel>(); var persons = PersonQueries.GetStaff(context).ToList(); foreach (var person in persons) { models.Add(MapPersonToPersonModel(context, person)); } return(models); } }
public void GetPersonsBetweenBirthDates_TwoDatesGiven_ReturnsPersons() { var bDate1 = RandomUtil.GetRandomDateInThePast(1); var person1 = CreatePerson(RandomUtil.GetRandomString(), RandomUtil.GetRandomString(), bDate1); var bDate2 = RandomUtil.GetRandomDateInThePast(1); var person2 = CreatePerson(RandomUtil.GetRandomString(), RandomUtil.GetRandomString(), bDate2); SwitchDatesIfNeeded(ref bDate2, ref bDate1); var persons = PersonQueries.GetPersonsBetweenBirthDates(Context, bDate1, bDate2); Assert.IsNotEmpty(persons); Assert.IsTrue(persons.Contains(person1)); Assert.IsTrue(persons.Contains(person2)); }
public void TestCreateGetSimplePersonDTOsQuery_CheckNames() { var person = new Person { Alias = "alias", FamilyName = "family", FirstName = "firstName", GivenName = "givenName", LastName = "lastName", MiddleName = "middleName", NamePrefix = "Mr.", NameSuffix = "III", Patronym = "patronym", FullName = "fullname", Gender = new Gender { GenderId = Gender.Female.Id, GenderName = Gender.Female.Value } }; var status = new ParticipantStatus { ParticipantStatusId = 1, Status = "status" }; var participant = new Participant { Status = status, Person = person, }; context.ParticipantStatuses.Add(status); person.Participations.Add(participant); context.People.Add(person); context.Genders.Add(person.Gender); var result = PersonQueries.CreateGetSimplePersonDTOsQuery(context).First(); Assert.AreEqual(person.Alias, result.Alias); Assert.AreEqual(person.FamilyName, result.FamilyName); Assert.AreEqual(person.FirstName, result.FirstName); Assert.AreEqual(person.GivenName, result.GivenName); Assert.AreEqual(person.LastName, result.LastName); Assert.AreEqual(person.MiddleName, result.MiddleName); Assert.AreEqual(person.NamePrefix, result.NamePrefix); Assert.AreEqual(person.Patronym, result.Patronym); Assert.AreEqual(person.FullName, result.FullName); }
/// <summary> /// Gets if the person is locked /// </summary> /// <param name="personId">The person id</param> /// <returns>If the person </returns> public async Task <bool> GetIsParticipantPersonLockedAsync(int personId) { var person = await PersonQueries.CreateGetSimplePersonDTOByIdQuery(this.Context, personId).FirstOrDefaultAsync(); var isParticipantPersonLocked = false; if (person != null && person.ProjectId.HasValue && person.ParticipantId.HasValue) { var participant = await GetParticipantPersonByIdAsync(person.ProjectId.Value, person.ParticipantId.Value); if (participant != null && participant.SevisStatusId.HasValue && Participant.LOCKED_SEVIS_COMM_STATUSES.Contains(participant.SevisStatusId.Value)) { isParticipantPersonLocked = true; } } return(isParticipantPersonLocked); }
private List <PersonModel> GetPlayers() { using (var context = new FcDeHoekContext()) { var models = new List <PersonModel>(); var persons = PersonQueries.GetPlayers(context).ToList(); foreach (var person in persons) { if (person.PerkezNumber != null) { models.Add(MapPersonToPersonModel(context, person)); } } return(models); } }
public override void SaveEntity_EntityExists_EntityIsUpdated() { var person = CreatePerson(); person.SavePerson(Context); Assert.IsNotNull(person); Assert.IsNotNull(person.IdPerson); var previousFirstName = person.FirstName; var newFirstName = RandomUtil.GetRandomString(15); person.FirstName = newFirstName; person.SavePerson(Context); var personDb = PersonQueries.GetPersonById(Context, person.IdPerson); Assert.AreNotEqual(previousFirstName, personDb.FirstName); Assert.AreEqual(newFirstName, personDb.FirstName); }
private object GetGameModel(FcDeHoekContext context, Game game) { var model = new FcDeHoekGameModel(); model.MatchDate = game.MatchDate; model.IdGame = game.IdGame; model.GameFixture = $"{game.GameHomeTeam.Name} - {game.GameAwayTeam.Name}"; model.GoalsHome = game.GoalsHomeTeam ?? 0; model.GoalsAway = game.GoalsAwayTeam ?? 0; model.AllGames = GetAllFcDeHoekGames(context, game.MatchDate); var players = PersonQueries.GetPlayers(context).ToList(); model.AllPlayers = SetAllPlayers(players); model.PlayersInGame = GetPlayersInGame(context, players, game.IdGame); return(model); }
private List <RecordsTempData> GetCurrentData(FcDeHoekContext context, List <RecordsTempData> historicData, int idSeason = -1) { var allPlayers = PersonQueries.GetPlayers(context).ToList(); foreach (var player in allPlayers) { var stats = PersonStatisticsQueries.GetByIdPerson(context, player.IdPerson).ToList(); if (stats.Any()) { var tempData = new RecordsTempData { IdPlayer = player.IdPerson, Player = $"{player.Name} {player.FirstName}" }; foreach (var stat in stats) { var game = GameQueries.GetById(context, stat.IdGame); if (game != null && game.IdCompetition == eCompetitionType.League && (game.IdSeason == idSeason || idSeason == -1)) { if ((stat.Goals != null && stat.Goals != 0) || stat.Assists != 0) { var playersHistoricData = historicData.FirstOrDefault(hd => hd.IdPlayer == player.IdPerson); if (playersHistoricData != null) { playersHistoricData.Assists += stat.Assists; playersHistoricData.Goals += stat.Goals ?? 0; } else { tempData.Assists += stat.Assists; tempData.Goals += stat.Goals ?? 0; historicData.Add(tempData); } } } } } } return(historicData); }
private void btnLoad_Click(object sender, EventArgs e) { if (cbDatabase.SelectedItem.ToString().Equals("SQL Server")) { conString = ConfigurationManager.ConnectionStrings["EasyDataSQLSERVER"].ConnectionString; dbManagerFactory = new SQLDBManagerFactory(conString); storedProcMap = new SQLServerStoredProcMap(); pQueries = new PersonQueries(dbManagerFactory, storedProcMap); } else if (cbDatabase.SelectedItem.ToString().Equals("Oracle")) { conString = ConfigurationManager.ConnectionStrings["EasyDataOracle"].ConnectionString; dbManagerFactory = new OracleDBManagerFactory(conString); sqlMap = new OracleSQLMap(); sqlMap.GetAllPeople = "select * from people"; pQueries = new PersonQueries(dbManagerFactory, sqlMap); } PopulatePeopleGrid(); }
public void TestCreateGetRelatedPersonByDependentFamilyMemberQuery_DepdendentDoesNotHaveFamily() { var spousePersonType = new DependentType { DependentTypeId = DependentType.Spouse.Id }; var dependent = new PersonDependent { DependentId = 10, DependentTypeId = spousePersonType.DependentTypeId, DependentType = spousePersonType }; context.PersonDependents.Add(dependent); context.DependentTypes.Add(spousePersonType); var result = PersonQueries.CreateGetRelatedPersonByDependentFamilyMemberQuery(context, dependent.DependentId).FirstOrDefault(); Assert.IsNull(result); }
private IQueryable <SimplePersonDTO> CreateGetSimplePerson(int personId) { var query = PersonQueries.CreateGetSimplePersonDTOsQuery(this.Context); return(query.Where(p => p.PersonId == personId)); }
public void GetPersonsBetweenBirthDates_NoPersonOnThatDayBorn_ReturnsEmptyList() { var bDate = RandomUtil.GetRandomDateInTheFuture(1); // Person will never have a birthday in the future ;p Assert.IsEmpty(PersonQueries.GetPersonsBetweenBirthDates(Context, bDate)); }
public override void GetEntityById_EntityDoesExist_ReturnsEntity() { var person = CreatePerson(); Assert.IsNotNull(PersonQueries.GetPersonById(Context, person.IdPerson)); }
public override void GetEntityById_EntityDoesNotExist_ReturnsNull() { Assert.IsNull(PersonQueries.GetPersonById(Context, -1)); }