Example #1
0
        public Boolean Add(int userid, int bookid)
        {
            try
            {
                var bookRequestService = new BookRequestService();
                BookRequest bookRequest = bookRequestService.GetByBook(bookid);

                var userService = new UserService();
                User user = userService.GetUserById(userid);

                var userBookRequest = new UserBookRequest {User = user, BookRequest = bookRequest, IsActive = 1};

                IList<UserBookRequest> userBookRequestList = new List<UserBookRequest>();
                userBookRequestList.Add(userBookRequest);

                var userBookRequestDal = new UserBookRequestDal();
                Boolean status = userBookRequestDal.Save(userBookRequestList);

                return status;

            }
            catch (Exception e)
            {
                Console.WriteLine("Some error in UserBookRequestService , Add()");
                Console.Write(e.ToString());
                return false;
            }
        }
Example #2
0
 public IList<UserBookRequest> FetchAllPendingRequests()
 {
     try
     {
         IUserBookRequestDal userBookRequestDal = new UserBookRequestDal();
         IList<UserBookRequest> userBookRequestsList = userBookRequestDal.ReadAllPending();
         return userBookRequestsList;
     }
     catch (Exception e)
     {
         Console.WriteLine("Error in BookRequestService , FetchPendingRequests()");
         Console.Write(e.ToString());
         return null;
     }
 }
Example #3
0
 public IList<UserBookRequest> DeleteBookRequestForUser(int userid, int bookid)
 {
     try
     {
         IUserBookRequestDal userBookRequestDal = new UserBookRequestDal();
         IList<UserBookRequest> userBookRequestsList = userBookRequestDal.ReadAllActiveRequestsForUser(userid);
         return userBookRequestsList;
     }
     catch (Exception e)
     {
         Console.WriteLine("Error in BookRequestService , DeleteBookRequestForUser()");
         Console.Write(e.ToString());
         return null;
     }
 }
Example #4
0
        public bool DeleteBookRequestForUser(int returnid)
        {
            try
            {
                IUserBookRequestDal userBookRequestDal = new UserBookRequestDal();
                UserBookRequest userBookRequest = userBookRequestDal.GetUserBookRequestById(returnid);
                userBookRequest.IsActive = 0;
                IList<UserBookRequest> userBookRequestList = new List<UserBookRequest>();
                userBookRequestList.Add(userBookRequest);
                Boolean status = userBookRequestDal.DeleteBookRequestForUser(userBookRequestList);

                return status;
            }
            catch (Exception e)
            {
                Console.WriteLine();
                Console.Write("Some error in UserBookRequestService , DeleteBookRequestForUser()");
                return false;
            }
        }
Example #5
0
        public IList<UserBookRequest> ReadAllActiveRequestsForUser(int userid)
        {
            try
            {
                var userBookRequestDal = new UserBookRequestDal();
                IList<UserBookRequest> userBookRequestList = userBookRequestDal.ReadAllActiveRequestsForUser(userid);
                IList<BookRequest> bookRequestList = new List<BookRequest>();

                return userBookRequestList;
            }
            catch (Exception e)
            {
                Console.WriteLine("Some error in UserBookRequestService , Read()");
                Console.Write(e.ToString());
                return null;
            }
        }