public int SaveBusModel(BusModel busModel) { if (busModel.ID == 0) { this._Context.BusModels.Add(busModel); this._Context.SaveChanges(); return(1); } else { var busModels = this._Context.BusModels .Where(o => o.ID == busModel.ID) .ToList(); if (busModels.Count <= 0) { return(0); } var dbEntry = busModels.First(); if (dbEntry != null) { dbEntry.Manufacturer = busModel.Manufacturer; dbEntry.Model = busModel.Model; dbEntry.Length = busModel.Length; dbEntry.Height = busModel.Height; dbEntry.PowerTrain = busModel.PowerTrain; this._Context.SaveChanges(); return(1); } } return(0); }
protected void Page_Load(object sender, EventArgs e) { BusModel s1 = new BusModel("3627", "706", "http://192.168.0.12", 80.0, 1772); DataGather s1Gather = new DataGather(s1); if (s1Gather.gatherFromArduino()) { //Complete } else { //Error Log } BusModel s2 = new BusModel("3612", "706", "http://192.168.0.12", 80.0, 1772); DataGather s2Gather = new DataGather(s2); if (s2Gather.gatherFromArduino()) { //Complete } else { //Error Log } }
public async Task <IActionResult> BusEdit(BusModel model) { BusRepository repo = new BusRepository(configModel.ConnectionString); BusModel bus; var user = await userManager.GetUserAsync(User); // Make sure the user is a maintenance worker if (!await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.BusMaintenance.ToString())) { return(Utilities.ErrorJson("Unauthorized")); } // Validate the input bus = repo.GetBus(model.Id); if (bus == null) { return(Utilities.ErrorJson("Invalid bus id")); } try { repo.UpdateBus(model.Id, model.LastMaintenance, model.LastOilChange, model.LastTireChange); } catch (Exception e) { return(Utilities.ErrorJson(e.Message)); } return(Utilities.NoErrorJson()); }
/// <summary> /// This function adds details of new bus in the database /// </summary> /// <param name="bus">object for BusModel</param> /// <returns>returns true or false</returns> public bool AddBusDetails(BusModel bus) { try { sqlConnection.Open(); using (SqlCommand sqlCommand = new SqlCommand("AddBusDetails", sqlConnection)) { sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.AddWithValue("@BusTravelsName", bus.BusTravelsName); sqlCommand.Parameters.AddWithValue("@BusSource", bus.BusSource); sqlCommand.Parameters.AddWithValue("@BusDestination", bus.BusDestination); sqlCommand.Parameters.AddWithValue("@BusDepartureDate", bus.BusDepartureDate); sqlCommand.Parameters.AddWithValue("@BusDepartureTime", bus.BusDepartureTime); sqlCommand.Parameters.AddWithValue("@BusSeatCount", bus.BusSeatCount); sqlCommand.Parameters.AddWithValue("@BusTicketCost", bus.BusTicketCost); sqlCommand.ExecuteNonQuery(); } } catch (SqlException sqlException) { log.Error(sqlException.ToString()); } finally { sqlConnection.Close(); } return(true); }
public void ChangeBus(string Name) { if (BusModule != null) { if (BusModule.Name != Name && MessageBox.Show("Do you want to change bus type?", "Question", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { this.Controls.Remove(BusModule); } else { return; } } Enum.TryParse(Name, out EnumBusType BusType); BusModule = new BusModel(BusType, new Point(100, this.Height / 2 + 100)); this.Controls.Add(BusModule); BusModule.BringToFront(); BusModule.OnModleDelete += UserControl1_OnModleDelete; BusModule.ControlMoveEvent += BusModule_ControlMoveEvent; BusModule_ControlMoveEvent(new object(), new ControlMoveEventArgs("")); OnProductChangedEvent?.Invoke(this, new ModuleAddedArgs() { IsAdd = true, Module = BusModule }); }
public async Task <ActionResult <BusModel> > PostBusModel(BusModel busModel) { _context.BusModels.Add(busModel); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBusModel", new { id = busModel.BusModelID }, busModel)); }
public async Task <IActionResult> PutBusModel(int id, BusModel busModel) { if (id != busModel.BusModelID) { return(BadRequest()); } _context.Entry(busModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BusModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public object Convert(object value, Type targetType, object parameter, string language) { if (value == null) { return("Unassigned"); } // Get driver name DriverModel driverModel = value as DriverModel; if (driverModel != null) { return(driverModel.DriverName); } // If we are here, we have a BusModel object, so let's convert BusModel busModel = value as BusModel; if (busModel != null) { return(busModel.BusTag); } return(value); }
public BusesEditViewModel() { busService = (App.Current as App).Container.GetService <IBusService>(); // Cast object to BusModel and assign busModelToEdit = busService.GetBusToEdit() as BusModel; // Set bus tag name for label BusTag = busModelToEdit.BusTag; PublishEditBusCommand = new RelayCommand( async() => { var messageDialog = new MessageDialog("Are you sure you want to commit these changes?", "Accept Bus Changes"); messageDialog.Commands.Add(new UICommand("Yes", null)); messageDialog.Commands.Add(new UICommand("No", null)); messageDialog.DefaultCommandIndex = 0; messageDialog.CancelCommandIndex = 1; var cmd = await messageDialog.ShowAsync(); if (cmd.Label == "Yes") { busService.EditBus(BusTag, NewBusTag, NewVRN); } NewBusTag = ""; NewVRN = ""; NavigationService.Navigate(typeof(BusesPage)); }); }
public ActionResult Dashboard(BusModel bus) { List<BusModel> busList = new List<BusModel>(); try { using (var client = new HttpClient()) { client.BaseAddress = new Uri(URL); var postTask = client.PostAsJsonAsync<BusModel>("CustomerAPI/DisplayBusDetails", bus); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { var postResponse = result.Content.ReadAsAsync<List<BusModel>>(); busList = postResponse.Result; } } } catch (Exception exception) { } return View(busList); }
public ActionResult AdminDashboard(BusModel bus) { List <BusModel> busDetails = new List <BusModel>(); try { using (var client = new HttpClient()) { client.BaseAddress = new Uri(URL); var get = client.GetAsync("AdminAPI/DisplayAllBusDetails"); get.Wait(); var result = get.Result; if (result.IsSuccessStatusCode) { var getBusDetails = result.Content.ReadAsAsync <List <BusModel> >(); getBusDetails.Wait(); busDetails = getBusDetails.Result; } } } catch (Exception exception) { } return(View(busDetails)); }
/// <summary> /// Display seats for customer to book /// </summary> /// <param name="bus">object for BusModel</param> /// <returns>view</returns> public ActionResult DisplaySeats(BusModel bus) { List<BusModel> seatList = new List<BusModel>(); try { var state = Session["CustomerEmail"]; if (state == null) { return RedirectToRoute("Login"); } using (var client = new HttpClient()) { client.BaseAddress = new Uri(URL); var get = client.GetAsync("CustomerAPI/DisplaySeats?BusID=" + bus.BusID); get.Wait(); var result = get.Result; if (result.IsSuccessStatusCode) { var getSeats = result.Content.ReadAsAsync<List<BusModel>>(); getSeats.Wait(); seatList = getSeats.Result; } } } catch (Exception exception) { } return View(seatList); }
static async Task Main(string[] args) { var rabbitBus = RabbitHutch.CreateBus(RabbitConfig, _ => { }); var logger = new LoggerConfiguration() .WriteTo.Console() .CreateLogger(); var bus = new BusModel(rabbitBus.Advanced); var rpc = new RpcModel(rabbitBus.Advanced); var logic = new BusinessLogic(bus, rpc, logger); await rpc.RegisterHandlerAsync("toxon.micro.router.register", async (requestMessage, _) => { var request = JsonMessage.Read <RegisterRouteRequest>(requestMessage); var response = await logic.RegisterRoute(request); return(JsonMessage.Write(new RegisterRouteResponse { Done = response })); }); await bus.RegisterHandlerAsync("toxon.micro.router.route", (message, _) => logic.RouteBusMessage(message)); await rpc.RegisterHandlerAsync("toxon.micro.router.route", (message, _) => logic.RouteRpcMessage(message)); logic.Start(); Console.WriteLine("Running Router... press enter to exit!"); Console.ReadLine(); }
public async Task <IActionResult> Edit(int id, [Bind("BusId,BusName,BusCompanyName,BusTitle,BusDescription,BusMap,BusRating,BusSeatType,BusSeatPrice,DepartureTime,BusDepartureLocation,BusArrivalLocation,ArrivalTime,ImageName")] BusModel busModel) { if (id != busModel.BusId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(busModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BusModelExists(busModel.BusId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(busModel)); }
public async Task <IActionResult> BusCreation(BusModel bus) { var user = await userManager.GetUserAsync(User); BusRepository busRepo = new BusRepository(configModel.ConnectionString); // Ensure that ONLY staff accounts have access to this API endpoint if (user == null || !await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.Staff.ToString())) { return(Utilities.ErrorJson("Not authorized")); } if (string.IsNullOrEmpty(bus.Name)) { return(Utilities.ErrorJson("Bus name cannot be empty")); } if (bus.Name.Length > 300) { return(Utilities.ErrorJson("Bus name is too long (limit 300 characters)")); } try { busRepo.CreateBus(bus.Name, bus.Route); } catch (Exception e) { return(Utilities.ErrorJson(e.Message)); } return(new JsonResult(new { Error = "" })); }
public ActionResult OtobusGoruntule() { BusModel bus = new BusModel(); bus.listOfBusses = new List <BusModel>(); bus.ShowBusStops(); return(View(bus)); }
public static void Postfix(BusModel __instance) { Random gen = new Random(); __instance.company = availCompaniesNew[Utils.RandomRangeI(0f, availCompaniesNew.Count - 1)]; __instance.vehicleModelName = availTypesNew[Utils.RandomRangeI(0f, availTypesNew.Count - 1)]; __instance.licensePlateNbr = GetRandomLetter().ToString() + GetRandomLetter() + GetRandomLetter() + gen.Next(0, 9) + gen.Next(0, 9) + gen.Next(0, 9); }
public async Task <Guid> Update(BusModel busModel) { var busEntity = _mapper.Map <BusEntity>(busModel); await _dbRepository.Update(busEntity); await _dbRepository.SaveChangesAsync(); return(busEntity.Id); }
public BusControllerTest() { _faker = new Faker(); _queueBus = new Mock <IQueueBus>(); _busController = new BusController(_queueBus.Object); _busModel = new BusModel { Message = _faker.Lorem.Paragraph() }; }
public void RemoveBus(object bus) { BusModel busModel = bus as BusModel; var busToDelete = Buses.Where(x => x == busModel).FirstOrDefault(); if (busToDelete != null) { Buses.Remove(busToDelete); } }
public void AddBus(string busTag, string vrn, Specs specs, Maintenance maintenance) { BusModel busModel = new BusModel() { BusTag = busTag, VRN = vrn, Specification = specs, BusMaintenance = maintenance, AssignedDriver = null }; Buses.Add(busModel); }
public async Task <IActionResult> Create([Bind("BusId,BusName,BusCompanyName,BusTitle,BusDescription,BusMap,BusRating,BusSeatType,BusSeatPrice,DepartureTime,BusDepartureLocation,BusArrivalLocation,ArrivalTime,ImageName")] BusModel busModel) { if (ModelState.IsValid) { _context.Add(busModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(busModel)); }
// GET: Bus public ActionResult Index() { BusModel model = new BusModel(); model.Bus = new Movilidad(); model.Buses = new List <Movilidad>(); model.Error = ""; model.Respuesta = ""; return(View(model)); }
public async Task <IActionResult> Update(BusModel model) { var result = await _busService.Update(model); if (result == Guid.Empty) { return(BadRequest("Bus not updated")); } return(Ok(result)); }
public ActionResult Edit(int Id) { Movilidad bus = new BusesClient().ObtenerMovilidad(Id); BusModel model = new BusModel(); model.Bus = bus; model.Buses = new List <Movilidad>(); model.Error = ""; model.Respuesta = ""; return(View("Index", model)); }
public ActionResult Add_Bus(BusModel busModel) { Bus bus = new Bus(); ViewBag.Bus = new SelectList(busRepository.GetBus(), "BusId", "BusNo"); bus.BusId = busModel.BusId; bus.BusNo = busModel.BusNo; bus.TotalSeat = busModel.TotalSeat; bus.Rate = busModel.Rate; busRepository.AddBus(bus); return(View()); }
public ActionResult OtobusGuncelle(int Id) { BusRouteModel otobusNumarasi = new BusRouteModel(); otobusNumarasi.busNumbersComboBoxDoldur = new List <int>(); otobusNumarasi.busNumbersComboBoxDoldur = otobusNumarasi.ShowBusNumbers(); BusModel bus = new BusModel(); bus.UpdateTheBus(Id); var tuple = new Tuple <BusRouteModel, BusModel>(otobusNumarasi, bus); return(View(tuple)); }
public async Task <ActionResult> SendAsync([FromBody] BusModel model) { try { await _queueBus.SendAsync(model.Message); return(Created("", null)); } catch (Exception exception) { return(BadRequest(exception)); } }
public BusModel BindIndexView() { BusModel busModal = new BusModel(); try { busModal.BusTypes = DBHelper.GetBusTypes(); } catch (System.Exception) { throw; } return(busModal); }
public BusModel[] GetPrint(bool _search, string nd, int rows, int page, string sidx, string sord, string filters = "") { var buses = new BusModel[] { }; var totalRecords = 0; using (var logic = new tblBusLogic()) { totalRecords = logic.Buses.Count(); buses = logic.GetPaged(_search, totalRecords, page, sidx, sord, filters) .Select(z => new BusModel(z)).ToArray(); } return(buses); }