Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .vs/AdvancedWebAPI/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .vs/AdvancedWebAPI/v17/.futdcache.v2
Binary file not shown.
Binary file modified .vs/AdvancedWebAPI/v17/.suo
Binary file not shown.
Binary file modified .vs/ProjectEvaluation/advancedwebapi.metadata.v5.2
Binary file not shown.
Binary file modified .vs/ProjectEvaluation/advancedwebapi.projects.v5.2
Binary file not shown.
Binary file not shown.
8 changes: 0 additions & 8 deletions AWA.Domain/Interfaces/IBusinessEntityContactRepository.cs

This file was deleted.

8 changes: 0 additions & 8 deletions AWA.Domain/Interfaces/IContactTypeRepository.cs

This file was deleted.

Binary file modified AWA.Domain/bin/Debug/net7.0/AWA.Domain.dll
Binary file not shown.
Binary file modified AWA.Domain/bin/Debug/net7.0/AWA.Domain.pdb
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fa3426309847ac656020e7966d6f021289e7e23a
7753c791ba0f150fa627e8f6142fd033d9f31034
Binary file modified AWA.Domain/obj/Debug/net7.0/AWA.Domain.dll
Binary file not shown.
Binary file modified AWA.Domain/obj/Debug/net7.0/AWA.Domain.pdb
Binary file not shown.
Binary file modified AWA.Domain/obj/Debug/net7.0/ref/AWA.Domain.dll
Binary file not shown.
Binary file modified AWA.Domain/obj/Debug/net7.0/refint/AWA.Domain.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion AWA.MinApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{
return await personService.GetAllPeople();
});
app.MapGet("/getPagedPeople", (HttpContext http, IPersonService personService, [AsParameters] PersonParameters personParameters) =>
app.MapGet("/getAdvancedPeople", (HttpContext http, IPersonService personService, [AsParameters] PersonParameters personParameters) =>
{
if (!personParameters.ValidYearRange)
{
Expand Down
Binary file modified AWA.MinApi/bin/Debug/net7.0/AWA.Domain.dll
Binary file not shown.
Binary file modified AWA.MinApi/bin/Debug/net7.0/AWA.Domain.pdb
Binary file not shown.
Binary file modified AWA.MinApi/bin/Debug/net7.0/AWA.MinApi.dll
Binary file not shown.
Binary file modified AWA.MinApi/bin/Debug/net7.0/AWA.MinApi.pdb
Binary file not shown.
Binary file modified AWA.MinApi/bin/Debug/net7.0/AWA.Repository.dll
Binary file not shown.
Binary file modified AWA.MinApi/bin/Debug/net7.0/AWA.Repository.pdb
Binary file not shown.
Binary file modified AWA.MinApi/bin/Debug/net7.0/AWA.Services.dll
Binary file not shown.
Binary file modified AWA.MinApi/bin/Debug/net7.0/AWA.Services.pdb
Binary file not shown.
Binary file not shown.
Binary file modified AWA.MinApi/obj/Debug/net7.0/AWA.MinApi.dll
Binary file not shown.
Binary file modified AWA.MinApi/obj/Debug/net7.0/AWA.MinApi.pdb
Binary file not shown.
18 changes: 0 additions & 18 deletions AWA.Repository/BusinessEntityContactRepository.cs

This file was deleted.

13 changes: 0 additions & 13 deletions AWA.Repository/ContactTypeRepository.cs

This file was deleted.

8 changes: 0 additions & 8 deletions AWA.Repository/UnitOfWork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,18 @@ public class UnitOfWork : IUnitOfWork

private readonly AdventureWorksContext _dbContext;

//public IBusinessEntityContactRepository BusinessEntityContacts { get; }

//public IContactTypeRepository ContactTypes { get; }

public IPersonRepository People { get; }

public IEmailAddressRepository EmailAddresses { get; }

public IEmployeeRepository Employees { get; }

public UnitOfWork(AdventureWorksContext dbContext,
//IBusinessEntityContactRepository businessEntityContactRepository,
//IContactTypeRepository contactTypeRepository,
IPersonRepository personRepository,
IEmailAddressRepository emailAddressRepository,
IEmployeeRepository employeeRepository)
{
this._dbContext = dbContext;
//this.BusinessEntityContacts = businessEntityContactRepository;
//this.ContactTypes = contactTypeRepository;
this.People = personRepository;
this.EmailAddresses = emailAddressRepository;
this.Employees = employeeRepository;
Expand Down
Binary file modified AWA.Repository/bin/Debug/net7.0/AWA.Domain.dll
Binary file not shown.
Binary file modified AWA.Repository/bin/Debug/net7.0/AWA.Domain.pdb
Binary file not shown.
Binary file modified AWA.Repository/bin/Debug/net7.0/AWA.Repository.dll
Binary file not shown.
Binary file modified AWA.Repository/bin/Debug/net7.0/AWA.Repository.pdb
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0982d8982f0bfc2b35b5636025dcbbd0e8a2b241
48a692c13b0359df347c3008e018440cbb6b43e8
Binary file modified AWA.Repository/obj/Debug/net7.0/AWA.Repository.dll
Binary file not shown.
Binary file modified AWA.Repository/obj/Debug/net7.0/AWA.Repository.pdb
Binary file not shown.
Binary file modified AWA.Repository/obj/Debug/net7.0/ref/AWA.Repository.dll
Binary file not shown.
Binary file modified AWA.Repository/obj/Debug/net7.0/refint/AWA.Repository.dll
Binary file not shown.
1 change: 1 addition & 0 deletions AWA.Services/DTOPeople.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public class DTOPeople
public string? EmailAddress { get; internal set; }
public DateTime BirthDate { get; internal set; }
public string? JobTitle { get; internal set; }
public string? FullName { get; internal set; } = null;
}
}
10 changes: 6 additions & 4 deletions AWA.Services/PersonParameters.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
namespace AWA.Services
{
public class PersonParameters:QueryStringParameters
public class PersonParameters : QueryStringParameters
{
public uint MinYearOfBirth { get; set; }
public uint MaxYearOfBirth { get; set; } = (uint)DateTime.Now.Year;
public bool ValidYearRange => MaxYearOfBirth > MinYearOfBirth;
public uint? MinYearOfBirth { get; set; }
public uint? MaxYearOfBirth { get; set; } = (uint)DateTime.Now.Year;
public bool ValidYearRange => (MaxYearOfBirth == null & MinYearOfBirth == null) || (MaxYearOfBirth > MinYearOfBirth);
public string? Name { get; internal set; } = "";
public string? JobTitle { get; internal set; } = "";
}
}
28 changes: 22 additions & 6 deletions AWA.Services/PersonService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public PersonService(IUnitOfWork unitOfWork)
}
public async Task<IEnumerable<DTOPeople>> GetAllPeople()
{
//var businessEntityContact = await _unitOfWork.BusinessEntityContacts.GetAll();
//var contactType = await _unitOfWork.ContactTypes.GetAll();
var people = await _unitOfWork.People.GetAll();
var emailAddress = await _unitOfWork.EmailAddresses.GetAll();
var employees = await _unitOfWork.Employees.GetAll();
Expand All @@ -30,7 +28,8 @@ join e in emailAddress on p.BusinessEntityId equals e.BusinessEntityId
LastName = p.LastName,
EmailAddress = e.EmailAddress1,
BirthDate = em.BirthDate,
JobTitle = em.JobTitle
JobTitle = em.JobTitle,
FullName = $"{p.FirstName} {p.LastName}"
}
);
return result;
Expand All @@ -40,10 +39,27 @@ join e in emailAddress on p.BusinessEntityId equals e.BusinessEntityId

public PagedList<DTOPeople> GetPagedPeople(PersonParameters personParameters)
{
var allPeople = GetAllPeople().Result.AsQueryable<DTOPeople>()
.Where(o => o.BirthDate.Year >= personParameters.MinYearOfBirth && o.BirthDate.Year <= personParameters.MaxYearOfBirth)
.OrderBy(so => so.FirstName);
var allPeople = GetAllPeople().Result.AsQueryable<DTOPeople>().OrderBy(so => so.FullName);
if (personParameters.MinYearOfBirth != null && personParameters.MaxYearOfBirth != null)
{
allPeople = (IOrderedQueryable<DTOPeople>)allPeople
.Where(o => o.BirthDate.Year >= personParameters.MinYearOfBirth && o.BirthDate.Year <= personParameters.MaxYearOfBirth);
}
SearchPeople(ref allPeople, personParameters.Name, personParameters.JobTitle);
return PagedList<DTOPeople>.ToPagedList(allPeople, personParameters.PageNumber, personParameters.PageSize);
}

private void SearchPeople(ref IOrderedQueryable<DTOPeople> allPeople, string? name, string? jobTitle)
{
if (allPeople.Any() == false) return;
if (string.IsNullOrWhiteSpace(name) && string.IsNullOrWhiteSpace(jobTitle)) return;
allPeople = ((IOrderedQueryable<DTOPeople>)(
from ap in allPeople
where (
(string.IsNullOrWhiteSpace(ap.FullName) || string.IsNullOrWhiteSpace(name) || ap.FullName.ToLower().Contains(name.Trim().ToLower())) &&
(string.IsNullOrWhiteSpace(ap.JobTitle) || string.IsNullOrWhiteSpace(jobTitle) || ap.JobTitle.ToLower().Contains(jobTitle.Trim().ToLower())))
select ap));

}
}
}
Binary file modified AWA.Services/bin/Debug/net7.0/AWA.Domain.dll
Binary file not shown.
Binary file modified AWA.Services/bin/Debug/net7.0/AWA.Domain.pdb
Binary file not shown.
Binary file modified AWA.Services/bin/Debug/net7.0/AWA.Services.dll
Binary file not shown.
Binary file modified AWA.Services/bin/Debug/net7.0/AWA.Services.pdb
Binary file not shown.
Binary file not shown.
Binary file modified AWA.Services/obj/Debug/net7.0/AWA.Services.dll
Binary file not shown.
Binary file modified AWA.Services/obj/Debug/net7.0/AWA.Services.pdb
Binary file not shown.
Binary file modified AWA.Services/obj/Debug/net7.0/ref/AWA.Services.dll
Binary file not shown.
Binary file modified AWA.Services/obj/Debug/net7.0/refint/AWA.Services.dll
Binary file not shown.