Skip to content

Service should allow given user id and librarian id to borrow an existing book or return it

Notifications You must be signed in to change notification settings

saedAgha/BookBorrowService

Repository files navigation

BookBorrowService

Service should allow given user id and librarian id to borrow an existing book or return it

System Requirements

Design a system that have :

  • Library (Support only single
  • Book ( can have multiple author’s , multiple copies)
  • Author (can have multiple books)
  • Librarian
  • Customer
  1. Borrow Book : given book id, librarian id and customer id Need to check if user can borrow a book ,and register request .

Possible edge cases :

  • Check if book id ,customer id , librarian id exist in DB
  • If user borrow same book in past and didn’t returned it , he can’t take another one .
  • Can take a book as long as it have number of copies greater than zero. Input : book id , librarian id , user id Output : defined true/false at the interview ( but would consider returning book title , number of copies left,list of authers)
  1. Return Book : given book id , librarian id ad customer id Need return the book.

Possible edge cases :

  • Check if book id ,customer id , librarian id exist in DB
  • Check if customer indeed borrowed the book in the past and didn’t returned it

Entities

image

Class UML

image

Swagger

image image

Unit tests

Xunit unit test project created to verify unit cases for services,validator and repositiory

Integration Test

xunit integration tests applied to cover e2e flows

Notes

  • entites fields I would prefer to encapsulate with private setters But for the sake of this homework i choosed not to implement to keep simplicity (In bigger development it should be encapsulated more offcourse)

  • in entites diagram you may notice that library contain Users and Books, in code i intentionally didnt added collection For both Users and Books because it wasn't a demand on requirements But i kept to be clear.

  • Library was defined as being single one , and for system requirements it was clear there's only one .

About

Service should allow given user id and librarian id to borrow an existing book or return it

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published