Пример #1
0
        public bool IssueBook(int libBookID, int memberID, out string serverSideError)
        {
            serverSideError = null;

            using (ProtoLibEntities context = new ProtoLibEntities())
            {
                LibraryBook libBook = (from lb in context.LibraryBooks
                                       where lb.BookID == libBookID
                                       select lb).SingleOrDefault();

                if (libBook != null)
                {
                    Member mem = (from m in context.Members
                                  where m.MemberID == memberID
                                  select m).SingleOrDefault();

                    if (mem != null)
                    {
                        Transaction t = new Transaction();
                        t.LibraryBook = libBook;
                        t.Member = mem;
                        t.Fine = 0.0;
                        t.CheckedOutOn = DateTime.Now;
                        t.ReturnedOn = null;

                        libBook.BookStatus = (from st in context.BookStatus1 where st.StatusID == 101 select st).Single();

                        context.Transactions.AddObject(t);
                        context.SaveChanges();
                        return true;
                    }
                    else
                    {
                        serverSideError = string.Format("No member with ID {0} exists", memberID.ToString());
                        return false;
                    }
                }
                else
                {
                    serverSideError = string.Format("No library book with that ID {0} exists", libBookID.ToString());
                    return false;
                }
            }
        }
        public static void TransactionDalToBll(ProtoLibEntities context, TransactionBLL bllTrans, Transaction dalTrans)
        {
            bllTrans.ItemID = dalTrans.TransactionID;

            bllTrans.BookID = dalTrans.BookID;
            bllTrans.MemberID = dalTrans.MemberID;
            bllTrans.CheckedOutOn = dalTrans.CheckedOutOn;
            bllTrans.ReturnedOn = dalTrans.ReturnedOn;
            bllTrans.Fine = dalTrans.Fine;
        }
        public static void TransactionBllToDal(ProtoLibEntities context, TransactionBLL bllTrans, Transaction dalTrans)
        {
            dalTrans.LibraryBook = (from lb in context.LibraryBooks where lb.BookID == bllTrans.BookID select lb).SingleOrDefault();
            dalTrans.Member = (from mem in context.Members where mem.MemberID == bllTrans.MemberID select mem).SingleOrDefault();

            dalTrans.CheckedOutOn = bllTrans.CheckedOutOn;
            dalTrans.ReturnedOn = bllTrans.ReturnedOn;

            dalTrans.Fine = bllTrans.Fine;
        }
Пример #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Transactions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTransactions(Transaction transaction)
 {
     base.AddObject("Transactions", transaction);
 }
Пример #5
0
 /// <summary>
 /// Create a new Transaction object.
 /// </summary>
 /// <param name="transactionID">Initial value of the TransactionID property.</param>
 /// <param name="bookID">Initial value of the BookID property.</param>
 /// <param name="memberID">Initial value of the MemberID property.</param>
 /// <param name="checkedOutOn">Initial value of the CheckedOutOn property.</param>
 /// <param name="fine">Initial value of the Fine property.</param>
 public static Transaction CreateTransaction(global::System.Int32 transactionID, global::System.Int32 bookID, global::System.Int32 memberID, global::System.DateTime checkedOutOn, global::System.Double fine)
 {
     Transaction transaction = new Transaction();
     transaction.TransactionID = transactionID;
     transaction.BookID = bookID;
     transaction.MemberID = memberID;
     transaction.CheckedOutOn = checkedOutOn;
     transaction.Fine = fine;
     return transaction;
 }