Exemple #1
0
        public ActionResult ReturnBook(int serial)
        {
            // You may have to cast serial to a (uint)
            try
            {
                using (Team6LibraryContext db = new Team6LibraryContext())
                {
                    // Create the CheckedOut object
                    CheckedOut checkedOut = new CheckedOut()
                    {
                        CardNum = (uint)card, Serial = (uint)serial
                    };

                    // Delete and save the new entry
                    db.CheckedOut.Remove(checkedOut);
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                // In case of exception, write it to debug in addition to throwing it
                System.Diagnostics.Debug.WriteLine(e);
                throw e;
            }

            return(Json(new { success = true }));
        }
Exemple #2
0
        public ActionResult CheckOutBook(int serial)
        {
            // Encapsulate in try/catch block in case of error
            try
            {
                using (Team6LibraryContext db = new Team6LibraryContext())
                {
                    // Create the CheckedOut object
                    CheckedOut checkedOut = new CheckedOut()
                    {
                        CardNum = (uint)card, Serial = (uint)serial
                    };

                    // Add and save the new entry
                    db.CheckedOut.Add(checkedOut);
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                // In case of exception, write it to debug in addition to throwing it
                System.Diagnostics.Debug.WriteLine(e);
                throw e;
            }

            // Placeholder
            return(Json(new { success = true }));
        }
        public ActionResult ReturnBook(int serial)
        {
            // Query the database for the rows to be deleted.

            using (Team8LibraryContext db = new Team8LibraryContext())
            {
                var query =
                    from co in db.CheckedOut
                    select new { co.Serial, co.CardNum };

                var retBook = new CheckedOut();
                foreach (var q in query)
                {
                    System.Diagnostics.Debug.WriteLine(q);
                    if (q.Serial == (uint)serial)
                    {
                        retBook.CardNum = q.CardNum;
                        retBook.Serial  = q.Serial;
                        db.CheckedOut.Remove(retBook);
                    }
                }

                db.SaveChanges();

                return(Json(new { success = true }));
            }
        }
Exemple #4
0
        public ActionResult CheckOutBook(int serial)
        {
            // You may have to cast serial to a (uint)
            CheckedOut newEntry = new CheckedOut()
            {
                Serial  = (uint)serial,
                CardNum = (uint)card
            };

            db.CheckedOut.Add(newEntry);
            db.SaveChanges();

            return(Json(new { success = true }));
        }
        public ActionResult CheckOutBook(int serial)
        {
            // You may have to cast serial to a (uint)
            using (Team8LibraryContext db = new Team8LibraryContext())
            {
                CheckedOut co = new CheckedOut();
                co.CardNum = (uint)card;
                co.Serial  = (uint)serial;
                db.CheckedOut.Add(co);
                db.SaveChanges();

                return(Json(new { success = true }));
            }
        }
 public ActionResult CheckOutBook(int serial)
 {
     // TODO: Implement
     // You may have to cast serial to a (uint)
     using (Team59LibraryContext db = new Team59LibraryContext())
     {
         CheckedOut c = new CheckedOut();
         c.Serial  = (uint)serial;
         c.CardNum = (uint)card;
         db.CheckedOut.Add(c);
         db.SaveChanges();
     }
     return(Json(new { success = true }));
 }
        public ActionResult ReturnBook(int serial)
        {
            CheckedOut c = new CheckedOut();

            c.CardNum = (uint)card;
            c.Serial  = (uint)serial;
            // You may have to cast serial to a (uint)
            using (Team75LibraryContext db = new Team75LibraryContext())
            {
                db.CheckedOut.Remove(c);
                db.SaveChanges();
                return(Json(new { success = true }));
            }
        }
        public ActionResult CheckOutBook(int serial)
        {
            using (Team89LibraryContext db = new Team89LibraryContext())
            {
                // You may have to cast serial to a (uint)
                CheckedOut book = new CheckedOut();
                book.Serial  = (uint)serial;
                book.CardNum = (uint)card;

                db.CheckedOut.Add(book);
                db.SaveChanges();
            }

            return(Json(new { success = true }));
        }
        public void Checkout(string selection)
        {
            Book selectedBook = ValidateBook(selection, AvailableBooks);

            if (selectedBook == null)
            {
                Console.Clear();
                System.Console.WriteLine(@"Invalid Selection");
                return;
            }
            selectedBook.Available = false;
            AvailableBooks.Remove(selectedBook);
            CheckedOut.Add(selectedBook);
            System.Console.WriteLine("Congrats my dude, you go it");
        }
        public ActionResult ReturnBook(int serial)
        {
            // You may have to cast serial to a (uint)
            using (Team69LibraryContext db = new Team69LibraryContext())
            {
                CheckedOut book = new CheckedOut
                {
                    CardNum = (uint)card,
                    Serial  = (uint)serial
                };
                db.CheckedOut.Remove(book);
                db.SaveChanges();
            }

            return(Json(new { success = true }));
        }
        public ActionResult CheckOutBook(int serial)
        {
            CheckedOut co = new CheckedOut
            {
                CardNum = Convert.ToUInt32(card),
                Serial  = Convert.ToUInt32(serial)
            };

            using (var cont = new Team45LibraryContext())
            {
                cont.CheckedOut.Add(co);
                cont.SaveChanges();
            }

            return(Json(new { success = true }));
        }
Exemple #12
0
        public ActionResult CheckOutBook(int serial)
        {
            using (Team45LibraryContext db = new Team45LibraryContext())
            {
                // Create a new CheckedOut object and fill in the cardnum and serial with the given serial
                // and global cardnum
                CheckedOut newCheckOut = new CheckedOut();
                newCheckOut.CardNum = (uint)card;
                newCheckOut.Serial  = (uint)serial;

                // Adds the new CheckedOut object to the CheckedOut table
                db.CheckedOut.Add(newCheckOut);
                db.SaveChanges();
            }

            return(Json(new { success = true }));
        }
        public ActionResult ReturnBook(int serial)
        {
            CheckedOut co = new CheckedOut
            {
                Serial  = (uint)serial,
                CardNum = (uint)card
            };

            using (Team34LibraryContext _context = new Team34LibraryContext())
            {
                _context.Remove(co);
                _context.SaveChanges();
            }
            return(Json(new
            {
                success = true
            }));
        }
Exemple #14
0
        public void Checkout(string selection)
        {
            Book selectedBook = ValidateBook(selection, AvailableBooks);

            if (selectedBook == null)
            {
                Console.Clear();
                System.Console.WriteLine("Invalid Selection");
                return;
            }
            else
            {
                selectedBook.Available = false;
                CheckedOut.Add(selectedBook);
                AvailableBooks.Remove(selectedBook);
                System.Console.WriteLine($"Congratulations on succesfully checking out {selectedBook.Title}! You have 2 weeks from today's date to return it. Enjoy!");
            }
        }
        public void ReturnBook(string selection)
        {
            Book selectedBook = ValidateBook(selection, CheckedOut);

            if (selectedBook == null || selectedBook.Available == true)
            {
                Console.Clear();
                System.Console.WriteLine(@"Invalid Selection");
                return;
            }
            else
            {
                selectedBook.Available = true;
                AvailableBooks.Add(selectedBook);
                CheckedOut.Remove(selectedBook);
                System.Console.WriteLine("Congrats my Dude, Book is back");
            }
        }
Exemple #16
0
        public void Return(string selection)
        {
            Book selectedBook = ValidateBook(selection, CheckedOut);

            if (selectedBook == null)
            {
                Console.Clear();
                System.Console.WriteLine("Invalid Selection");
                return;
            }
            else
            {
                selectedBook.Available = true;
                CheckedOut.Remove(selectedBook);
                AvailableBooks.Add(selectedBook);
                System.Console.WriteLine($"Congratulations on succesfully returning {selectedBook.Title}! We hope you enjoyed the read, and please feel free to check out more!");
            }
        }
Exemple #17
0
        public ActionResult CheckOutBook(int serial)
        {
            // You may have to cast serial to a (uint)
            CheckedOut co = new CheckedOut {
                CardNum = (uint)card, Serial = (uint)serial
            };

            using (Team12LibraryContext db = new Team12LibraryContext()) {
                db.CheckedOut.Add(co);
                try {
                    db.SaveChanges();
                }
                catch (Exception e) {
                    System.Diagnostics.Debug.WriteLine(e.Message);
                    return(Json(new { sucess = false }));
                }
            }

            return(Json(new { success = true }));
        }
        public void Return(int pieceId, int musicianId, String cond)
        {
            Piece      p  = _context.Piece.Find(pieceId);
            CheckedOut co = _context.CheckedOut.Find(musicianId, pieceId);
            float      rating;

            if (cond.Equals("Excellent"))
            {
                rating = 5;
            }
            else if (cond.Equals("Good"))
            {
                rating = 4;
            }
            else if (cond.Equals("Fair"))
            {
                rating = 3;
            }
            else if (cond.Equals("Poor"))
            {
                rating = 2;
            }
            else if (cond.Equals("Awful"))
            {
                rating = 1;
            }
            else
            {
                _context.Remove(co);
                _context.SaveChanges();
                return;
            }

            //The new rating will be the weighted average of the old rating with the condition of the returned part.
            float newRating = (p.AggregateRating * (p.NumberofParts - 1) + rating) / p.NumberofParts;

            p.AggregateRating = newRating;
            _context.Update(p);
            _context.Remove(co);
            _context.SaveChanges();
        }
    public Task Handle(CheckOut message, IMessageHandlerContext context)
    {
        //cannot check out unless it checked in already
        if (Data.BookingItem.Status != Constants.CheckedIn)
        {
            log.Error($"Cannot check out booking #{message.BookingNumber} .");
            return(Task.CompletedTask);
        }

        Data.BookingItem.Status = Constants.CheckedOut;

        log.Info($"Booking #{message.BookingNumber} Checked out.");

        var checkedIn = new CheckedOut
        {
            BookingNumber = message.BookingNumber,
            ClientId      = message.ClientId
        };

        return(context.Publish(checkedIn));
    }