-
Notifications
You must be signed in to change notification settings - Fork 2
ILawyerService
This service provides access to queries and CRUD operations on Lawyer entities. It also provides abstractions to many-to-many relationships that use junction tables to reduce the overall complexity of these operations. It contains the following method signature(s):
Task<Lawyer> GetLawyerByPrincipalAsync(ClaimsPrincipal principal);
Task<Lawyer> FindAsync(string id);
Task<bool> TryUpdateAsync(Lawyer lawyer);
Task<bool> LockOutAsync(string id);
Task<IEnumerable<LawyerSchedule>> GetSchedulesAsync(string lawyerId);
Task<bool> AddScheduleAsync(LawyerSchedule lawyerSchedule);
Task<bool> UpdateScheduleAsync(LawyerSchedule lawyerSchedule);
Task<bool> DeleteScheduleAsync(LawyerSchedule lawyerSchedule);
Task<bool> AddLibraryToLawyerAsync(string lawyerId, long libraryId);
Task<bool> RemoveLibraryFromLawyerAsync(string lawyerId, long libraryId);
Task<bool> MergeLibraryListWithLawyerAsync(string lawyerId, IEnumerable<long> libraryIds);
Task<bool> MatchWithVeteranAsync(string lawyerId, string veteranId);
Task<bool> VerifyBarStatus(string id);
These are implemented within the LawyerService model. This where a majority of the interactions regarding lawyer information will be handled through the application. Refer below for more information regarding the methods.
This method is used to find a specific lawyer within the database via an id. This id is created through registration process and is stored via Identity which is why in this instance the variable is of type string.
This method is used to find a Lawyer by a given Claims principle. Inside the method we check to see if Identity has a lawyer with a given principle. A null is returned if the user given to us by Identity is null otherwise we continue by including the schedules and libraries associated with that user id.
This method is how we retrieve schedules based off of a given lawyerId. We use the lawyerId as our parameter to create a list of schedules from the LawyerSchedules table.
This method is used to add a schedule to a specific lawyer. It takes in a paramater of type LawyerSchedule. It first checks if the incoming parameter is null and if it is, it will log the information and return a false. If it passes this check, it will add the changes to the database. There is a try-catch to save the changes to the database in which if it is successful, it will return a true, otherwise it will log the error and return false
Method that will update the incoming schedule in the database. It takes in a parameter of type LawyerSchedule. The method first checks if the incoming parameter is null or if the requested schedule doesn't exist within the database, it will log an error and return a false. After this check, the method proceeds to update the database with the incoming schedule information. Then in a try-catch block, it will try to save the changes and if it is successful it will return a true or catch and log the error and return a false
This method is used to removed the specific schedule in the database. It takes in a parameter of type LawyerSchedule. It will first check if the incoming parameter is null or if the requested schedule doesn't exist within the databse, it will log an error and return a false. After this check, it will remove the schedule from the database. Then in a try-catch block, it will attempt to save the changes and on success will return a true or catch and log the error then return false.
Method that adds a specific library to a specific lawyer. It takes in the parameters of type string lawyerId and string libraryId. It first will check if the connection already exists and will return false if it does. After this check, the method proceeds to create a LawyerLibraryJunction with the lawyerId and the libraryId and storing that within the LawyerLibraryJunction table. Then in a try-catch block it tries to save the changes to the database and returns true on success or catches the error and logs it, returning a false.
This method is used to remove a specific library from the associated lawyer id. It takes in the parameters of type string lawyerId and string libraryId. First, the method takes these two parameters to create a LawyerLibraryJunction object named junction. After, junction is checked to see if it is null at which point it will log the error and return false. After this check, it will then remove the requested junction from the database. In a try-catch block, it will try to save the changes and return a true or catch the error and log it, returning a false.
This method is used to perform CRUD operations on the many-to-many relationships between a specific lawyer and specific library. This takes in the parameters of type string lawyerId and IEnumerable< long > libraryIds. Based off of the incoming libraryIds and lawyerId, a call is made to the database to get the existing relationships stored in currentLibraryIds. After, the libraryIds are then iterated through except those that exist within the currentLibraryIds and a new LawyerLibraryJunction is added per libraryId.
After this call, The method iterates through the currentLibraryIds except those matching the libraryIds and is removing old relationships between the Lawyer and associated Libraries. Following that there is a try-catch block that attempts to save the changes to the database and will return true on success or it will catch the error and log it, returning a false.
This method is used to create a match between a veteran and a lawyer at a given library. This takes in the parameters of type string lawyerId, string veteranId, string libraryName. First with the veteranId, a check is made to see if that specific veteran already has a match. If so, a logged error and false are returned. Another check is in place to see if the requested lawyer or veteran doesnot exist. If that is true, a logged error and false are returned.
After these checks, a new VeteranLawyerMatch object is created and added using the three incoming parameters to the database. Within a try-catch, the database attempts to save these changes, log the success and return a true. Otherwise it will catch the error, logging it and returning a false.
Currently Not implemented
Currently Not implemented
Currently Not implemented