Skip to content

IVeteranService

Earl Jay edited this page Aug 10, 2018 · 4 revisions

This service allows users to do CRUD operations on tables that are associated with Veteran or VeteranLibraryJunction classes:

        Task<Veteran> GetVeteranByPrincipalAsync(ClaimsPrincipal principal);
        Task<bool> MergeLibraryListWithVeteranAsync(string veteranId, IEnumerable<long> libraryIds);
        Task<IEnumerable<Veteran>> GetPotentialClientsForLawyerAsync(string lawyerId);
        Task<Veteran> FindVeteranAsync(string id);
        Task<IEnumerable<VeteranLibraryJunction>> GetVeteranLibraryJunctionsAsync(string veteranId);

These methods are implemented within the VeteranService model, which handles CRUD operations involving veteran users. Refer to the information below for more information on these methods.


GetVeteranByPrincipalAsync(ClaimsPrincipal principal)

This method is used to find a specific veteran in the database through their ClaimsPrincipal. Due to the authorization nature of Identity, this method will get the Veteran object of the veteran user currently logged in.


MergeLibraryListWithVeteranAsync(string veteranId, IEnumerable libraryIds)

This method is used to update the list of libraries that the veteran has chosen. It takes the current library IDs of the libraries chosen by the veteran. It then iterates through the list of input libraryIds and then adds and removes library IDs so that the VeteranLibraryJunction table has an updated list of library IDs associated with the given veteran.


GetPotentialClientsForLawyerAsync(string lawyerId)

This method retrieves a list of veterans that match as potential candidates for a lawyer based on the lawyerId string given. Veterans match if they pick one of the libraries that a lawyer has associated themselves with. This list is retrieved through a series of LINQ queries.


FindVeteranAsync(string id)

This method finds a veteran based on the input id (primary key) given.


GetVeteranLibraryJunctionsAsync(string veteranId)

This method finds an IENumerable list of all VeteranLibraryJunction objects related a veteran based on the given veteranID.