Esempio n. 1
0
        protected void Reserve(GridViewRow row)
        {
            var copy = GetAvailableCopy(row);

            if (copy == null)
            {
                status.Text = "No Copies Available to be reserved.";
            }
            else
            {
                using (var db = new LibraryEntities())
                {
                    int        id          = int.Parse(Context.User.Identity.Name);
                    Customer   customer    = db.Customers.First(x => x.Id == id);
                    Resevation reservation = new Resevation()
                    {
                        ReservationDate = DateTime.UtcNow,
                        CustomerId      = customer.Id,
                        Copy            = copy
                    };

                    db.Resevations.Add(reservation);
                    db.SaveChanges();
                }
            }
        }
Esempio n. 2
0
        protected void Submit(object sender, EventArgs e)
        {
            Librarian newCustomer = new Librarian()
            {
                FirstName = firstName.Text,
                LastName  = lastName.Text,
                Email     = email.Text,
                Phone     = phone.Text,
            };

            try
            {
                using (LibraryEntities db = new LibraryEntities())
                {
                    db.Librarians.Add(newCustomer);
                    db.SaveChanges();

                    firstName.Text = "";
                    lastName.Text  = "";
                    email.Text     = "";
                    phone.Text     = "";

                    status.Text = "Successfully added!";
                }
            }
            catch (IndexOutOfRangeException)
            {
                status.Text = "Additional unsucessful, please try again!";
            }
        }
Esempio n. 3
0
        protected void Submit(object sender, EventArgs e)
        {
            Media newMedia = new Media()
            {
                Title       = title.Text,
                Author1     = author.Text,
                ISBN1       = isbn.Text,
                Year        = year.Text,
                Publisher   = publisher.Text,
                Genre       = genre.Text,
                Description = description.Text,
            };

            try
            {
                using (LibraryEntities db = new LibraryEntities())
                {
                    db.Media.Add(newMedia);
                    db.SaveChanges();

                    title.Text       = "";
                    author.Text      = "";
                    isbn.Text        = "";
                    year.Text        = "";
                    publisher.Text   = "";
                    genre.Text       = "";
                    description.Text = "";

                    status.Text = "Successfully added!";
                }
            }
            catch (IndexOutOfRangeException)
            {
                status.Text = "Additional unsucessful, please try again!";
            }
        }