示例#1
0
        /// <summary>
        /// Refresh the <see cref="Control"/>s contained in the <see cref="Menu"/>
        /// </summary>
        public void Refresh()
        {
            Loanee loanee = Library.GetLibrary.GetLoanee(CurrentItemID);

            #region Refresh Header
            Header.Text     = ((loanee != null) ? (loanee.Name) : ("Error"));
            Header.Position = new Vector2(Vector2.CenterX(Header.Text.Length + 2), HeaderPosY);
            #endregion

            #region Refresh ID
            string id = ((loanee != null) ? (loanee.ID.ToString()) : ("Error"));
            idText.Text = string.Format("{0,6}", id);

            idLabel.Position = new Vector2(Vector2.CenterX(idLabel.Size.x + idText.Text.Length + 2), HeaderPosY + HeaderOffset);
            idText.Position  = new Vector2(idLabel.Position.x + idLabel.Size.x - 1, HeaderPosY + HeaderOffset);
            #endregion

            #region Refresh Email
            string email = ((loanee != null) ? (loanee.Email) : ("Error"));
            emailText.Text = email;

            emailLabel.Position = new Vector2(Vector2.CenterX(emailLabel.Size.x + emailText.Text.Length + 2), idLabel.Position.y + 3);
            emailText.Position  = new Vector2(emailLabel.Position.x + emailLabel.Size.x - 1, emailLabel.Position.y);
            #endregion
        }
示例#2
0
        /// <summary>
        /// Remove a <see cref="Loanee"/>, from the collection based on <paramref name="_email"/>
        /// </summary>
        /// <param name="_id"></param>
        /// <returns><see langword="true"/> if the <see cref="Loanee"/> could be removed; Otherwise <see langword="false"/></returns>
        public bool RemoveLoanee(string _email)
        {
            Loanee loanee = loanees.Find(item => item.Email.ToLower() == _email.ToLower());

            if (loanee != null)
            {
                loanees.Remove(loanee);
                return(true);
            }

            return(false);
        }
示例#3
0
        /// <summary>
        /// Remove a <see cref="Loanee"/> from the collection, based on <paramref name="_id"/>
        /// </summary>
        /// <param name="_id"></param>
        /// <returns><see langword="true"/> if the <see cref="Loanee"/> could be removed; Otherwise <see langword="false"/></returns>
        public bool RemoveLoanee(int _id)
        {
            Loanee loanee = loanees.Find(item => item.ID == _id);

            if (loanee != null)
            {
                loanees.Remove(loanee);
                return(true);
            }

            return(false);
        }
示例#4
0
        /// <summary>
        /// Create a new instance of type <see cref="Loanee"/> and adds it to the collection
        /// </summary>
        /// <param name="_name"></param>
        /// <param name="_email"></param>
        /// <returns><see langword="true"/> if a <see cref="Loanee"/> with the same <paramref name="_email"/> does <strong>not</strong> already exist; Otherwise <see langword="false"/></returns>
        public bool CreateLoanee(string _name, string _email, out Loanee _loanee)
        {
            if (loanees.Find(item => item.Email.ToLower() == _email.ToLower()) == null)
            {
                Loanee loanee = new Loanee(_name, _email);
                loanees.Add(loanee);
                _loanee = loanee;
                return(true);
            }

            _loanee = null;
            return(false);
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="_isbnCode"></param>
        /// <returns><see langword="true"/> if the book could be borrowed; Otherwise <see langword="false"/></returns>
        public bool BorrowBook(Loanee _loanee, string _isbnCode)
        {
            Book book = GetBook(_isbnCode);

            if (book != null && !book.IsBorrowed)
            {
                _loanee.BorrowedBooks.Add(book);
                book.IsBorrowed    = true;
                book.DateOfLending = DateTime.Now;
                return(true);
            }

            return(false);
        }