public void AddBus(Bus bus) { var coll = _database.GetCollection(_busCollectionName); coll.Save(bus); }
public ActionResult AddNewBus(int capacity, string license, string state) { DatabaseInterface db = new DatabaseInterface(); if (!db.IsLicenseUnique(license)) return Json("false"); Bus bus = new Bus() { Id = ObjectId.GenerateNewId(), LicensePlate = license, BusId = db.GetNextBusId(), Status = BusStatus.Active, Capacity = capacity, State = state, AssignedTo = -1 }; db.AddBus(bus); return Json(new{ success = "true", id = bus.Id.ToString() }); }
public void UpdateBus(Bus bus) { var coll = _database.GetCollection(_busCollectionName); coll.Remove(Query.EQ("BusId", bus.BusId)); coll.Save(bus); }