public Route AddRoute(Route route)
 {
     _db.Routes.Add(route);
     _db.SaveChanges();
     return(route);
 }
Exemplo n.º 2
0
 public Trip AddTrip(Trip trip)
 {
     _db.Trips.Add(trip);
     _db.SaveChanges();
     return(trip);
 }
 public BusDetails AddBus(BusDetails busDetails)
 {
     _db.Buses.Add(busDetails);
     _db.SaveChanges();
     return(busDetails);
 }
Exemplo n.º 4
0
        public IActionResult BookedSeatsData(int id)
        {
            ViewBag.UserName = User.Identity.Name;
            if (User.Identity.IsAuthenticated)
            {
                var userName = User.Identity.Name;
                var booked   = _db.BookedSeats.Include(e => e.Trips).Include(e => e.Trips.Route).Include(e => e.Trips.BusDetails).Where(e => e.TripsID == id).FirstOrDefault();


                if (booked == null)
                {
                    var books = new BookedSeats
                    {
                        UserId  = userName,
                        TripsID = id,
                        A1      = 0,
                        A2      = 0,
                        A3      = 0,
                        A4      = 0,
                        A5      = 0,
                        A6      = 0,
                        A7      = 0,
                        A8      = 0,
                        A9      = 0,
                        A10     = 0,
                        B1      = 0,
                        B2      = 0,
                        B3      = 0,
                        B4      = 0,
                        B5      = 0,
                        B6      = 0,
                        B7      = 0,
                        B8      = 0,
                        B9      = 0,
                        B10     = 0,
                        C1      = 0,
                        C2      = 0,
                        C3      = 0,
                        C4      = 0,
                        C5      = 0,
                        C6      = 0,
                        C7      = 0,
                        C8      = 0,
                        C9      = 0,
                        C10     = 0
                    };
                    _db.BookedSeats.Add(books);
                    _db.SaveChanges();
                    return(View(books));
                }
                else
                {
                    booked.UserId  = userName;
                    booked.TripsID = id;
                }
                return(View(booked));
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }