예제 #1
0
 public ActionResult Book(Booking booking)
 {
     if (ModelState.IsValid)
     {
         using (PonyContext db = new PonyContext())
         {
             db.Bookings.Add(booking);
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     return(View(booking));
 }
예제 #2
0
        public ActionResult Book(int id)
        {
            PonyContext db      = new PonyContext();
            Pony        pony    = db.Ponies.Find(id);
            Booking     booking = new Booking();

            ViewBag.Pony       = pony.Name;
            ViewBag.Picture    = pony.Picture;
            ViewBag.PonyID     = pony.ID;
            ViewBag.CustomerID = User.Identity.GetUserId();
            booking.Day        = DateTime.Today;
            booking.PonyID     = pony.ID;
            booking.CustomerID = User.Identity.GetUserId();
            return(View(booking));
        }
예제 #3
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         using (PonyContext db = new PonyContext())
         {
             Pony pony = db.Ponies.Find(id);
             if (pony != null)
             {
                 db.Ponies.Remove(pony);
             }
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
예제 #4
0
 public ActionResult Index()
 {
     using (PonyContext db = new PonyContext())
     {
         var                userid       = User.Identity.GetUserId();
         List <Booking>     bookings     = db.Bookings.Where(x => x.CustomerID == userid).OrderBy(x => x.Day).ToList();
         List <BookingList> bookingsList = new List <BookingList>();
         BookingList        bookingList;
         foreach (Booking booking in bookings)
         {
             bookingList             = new BookingList();
             bookingList.Day         = booking.Day.ToShortDateString();
             bookingList.Session     = getSession(booking.Session);
             bookingList.PonyName    = db.Ponies.Find(booking.PonyID).Name;
             bookingList.PonyPicture = db.Ponies.Find(booking.PonyID).Picture;
             bookingList.SessionID   = booking.ID;
             bookingsList.Add(bookingList);
         }
         return(View(bookingsList));
     }
 }
예제 #5
0
        // GET: BrowsePonies
        public ActionResult Index()
        {
            PonyContext db = new PonyContext();

            return(View(db.Ponies.ToList()));
        }