Ejemplo n.º 1
0
        public static object checkForResetPassword(string mail)
        {
            Users user = DalUser.login(mail, null);

            if (user != null)
            {
                string mailSubject = "Bookmark-reset password";
                if (BLSendinMail.SendingEmail(buildMailBodyForResetPassword(user), mailSubject, mail))//sending mail

                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
    public static bool addLending(Lendings lending)
    {
      BooksInLibrary book = BLBook.getBook(lending.IdBook);//gettin book according to bookId
      Users user = BLUser.getUser(lending.IdUser);//gettin user according to userId
      lending.StartDate = DateTime.Now;//setting the lend date for today
      lending.EndDate = lending.StartDate.AddDays(Convert.ToDouble(book.LendingDuration));
      //setting the lend expiration date for today plus the borrowing time
      Lendings newLending = DalLending.addLending(lending);//add new lending
      if (newLending != null)
      {
        if (changeBookStatuse(lending.IdBook, 3)) //3 means catch-statusLending table(1-borrowed,2-free,3-catch)
        {
          Books bookObj = BLBook.getBookObj(book.IdBook);
          string mailSubject = "lending book";
          if (BLSendinMail.SendingEmail(buildMailBodyForLending(lending, user.FirstName, bookObj.NameBook), mailSubject, user.EMail))//sending mail
          {
            return true;

          }
          else
          {
            DalLending.deleteLending(newLending.IdLending);//if can't send email deleting the lending from the DB
            return false;
          }
        }
        else
        {
          DalLending.deleteLending(newLending.IdLending);//if can't change the status of the book(to catch) deleting the lending from the DB
          return false;
        }
      }
      else
      {
        return false;//if can't create the new lending deleting the lending from the DB
      }
    }