예제 #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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #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();
        }
예제 #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));
        }
예제 #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));
        }
예제 #10
0
        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"));
        }
예제 #11
0
        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();
        }
예제 #12
0
        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();
        }
예제 #13
0
        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"));
        }
예제 #14
0
        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();
        }
예제 #15
0
 public ActionResult BusAdd(Bus bus)
 {
     db.Buses.Add(bus);
     db.SaveChanges();
     return(RedirectToAction("BusesList"));
 }
예제 #16
0
 public void Create(TEntity entity)
 {
     _context.Add(entity);
     _context.SaveChanges();
 }
예제 #17
0
 public void Save()
 {
     _context.SaveChanges();
 }