Exemple #1
0
        public IHttpActionResult PutTrip(int id, Trip trip)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != trip.TripID)
            {
                return(BadRequest());
            }

            db.Entry(trip).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TripExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #2
0
        public ActionResult Create([Bind(Include = "ID,Name,Brand,Color,Seats")] Bus bus)
        {
            if (ModelState.IsValid)
            {
                db.Bus.Add(bus);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bus));
        }
Exemple #3
0
        public ActionResult Create([Bind(Include = "ClientID,Name,Surname,Birthdate,Email")] Client client)
        {
            if (ModelState.IsValid)
            {
                db.Clients.Add(client);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(client));
        }
Exemple #4
0
        public ActionResult Create([Bind(Include = "BusID,Capacity,Company,Class")] Bus bus)
        {
            if (ModelState.IsValid)
            {
                db.Buses.Add(bus);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bus));
        }
Exemple #5
0
        public ActionResult Create([Bind(Include = "CityID,CityName")] City city)
        {
            if (ModelState.IsValid)
            {
                db.Cities.Add(city);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(city));
        }
Exemple #6
0
        public ActionResult Create([Bind(Include = "SeatID,BusID")] Seat seat)
        {
            if (ModelState.IsValid)
            {
                db.Seats.Add(seat);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(seat));
        }
Exemple #7
0
        public void Create(AddressCreateDto createDto)
        {
            var address = _busContext.Addresses.FirstOrDefault(x => x.LongUrl == createDto.LongUrl);

            if (address != null)
            {
                return;
            }

            _busContext.Addresses.Add(new Address(createDto.LongUrl));
            _busContext.SaveChanges();
        }
Exemple #8
0
        public ActionResult Create([Bind(Include = "BookingID,ClientID,SeatID,BusID,TripID")] Booking booking)
        {
            if (ModelState.IsValid)
            {
                db.Bookings.Add(booking);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ClientID = new SelectList(db.Clients, "ClientID", "Name", booking.ClientID);
            ViewBag.SeatID   = new SelectList(db.Seats, "SeatID", "SeatID", booking.SeatID);
            ViewBag.TripID   = new SelectList(db.Trips, "TripID", "TripID", booking.TripID);
            return(View(booking));
        }
Exemple #9
0
        public ActionResult Create([Bind(Include = "TripID,BusID,OriginID,DestinationID,Price,DateTimeTrip")] Trip trip)
        {
            if (ModelState.IsValid)
            {
                db.Trips.Add(trip);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BusID         = new SelectList(db.Buses, "BusID", "Company", trip.BusID);
            ViewBag.DestinationID = new SelectList(db.Cities, "CityID", "CityName", trip.DestinationID);
            ViewBag.OriginID      = new SelectList(db.Cities, "CityID", "CityName", trip.OriginID);
            return(View(trip));
        }
        public ActionResult RequestAdd(Request model)
        {
            Request reqest = new Request
            {
                clientEmail   = model.clientEmail,
                date          = DateTime.Now,
                path          = model.path,
                departureDate = model.departureDate,
                returnDate    = model.returnDate,
                busID         = model.busID,
            };

            db.Requests.Add(reqest);
            db.SaveChanges();

            return(RedirectToAction("BusesList", "Bus"));
        }
        public static void AddRoute(BusContext db, string name)
        {
            var id = new BusRouteId(int.Parse(name));
            var r  = new BusRoute(id, name);

            db.Add(r.State);
            db.SaveChanges();
        }
        public static void AddBus(BusContext db, string number, string seated, string standing)
        {
            var seatingCapacity  = int.Parse(seated);
            var standingCapacity = int.Parse(standing);

            var id = new BusId(Guid.NewGuid());
            var b  = new Bus(id, number, seatingCapacity, standingCapacity);

            db.Add(b.State);
            db.SaveChanges();
        }
        public ActionResult WaybillAdd(Waybill model)
        {
            Waybill waybill = new Waybill
            {
                date          = DateTime.Now,
                path          = model.path,
                departureDate = model.departureDate,
                returnDate    = model.returnDate
            };

            db.Waybills.Add(waybill);
            db.SaveChanges();

            return(RedirectToAction("WaybillsList", "Waybill"));
        }
        public static void ScheduleBus(BusContext db, string busNumber, string routeName)
        {
            //pretend this is in a repository
            var bus   = Bus.FromMemento(db.Buses.Single(b => b.BusNumber == busNumber));
            var route = BusRoute.FromMemento(db.BusRoutes.Single(r => r.Id == int.Parse(routeName)));

            var schedule = new ScheduledService(new ScheduledServiceId(Guid.NewGuid()), bus.Id, route.Id);

            if (busNumber.StartsWith("A"))
            {
                schedule.Activate();
            }

            db.Services.Add(schedule.State);
            db.SaveChanges();
        }
 public ActionResult BusAdd(Bus bus)
 {
     db.Buses.Add(bus);
     db.SaveChanges();
     return(RedirectToAction("BusesList"));
 }
 public void Create(TEntity entity)
 {
     _context.Add(entity);
     _context.SaveChanges();
 }
Exemple #17
0
 public void Save()
 {
     _context.SaveChanges();
 }