public static async void GetCountdown(int CountdownId) { string baseURL = $"http://pokeapi.co/api/v2/pokemon/{CountdownId}/"; try { using (HttpClient client = new HttpClient()) { using (HttpResponseMessage res = await client.GetAsync(baseURL)) { using (HttpContent content = res.Content) { string data = await content.ReadAsStringAsync(); if (data != null) { var dataObj = JObject.Parse(data); CountdownModel countdown = new CountdownModel(remainingTime: Int32.Parse($"{dataObj["RemainingTime"]}")); } else { Console.WriteLine("Data is null!"); } } } } } catch (Exception exception) { Console.WriteLine(exception); } }
public async Task <IActionResult> PutCountdownModel(long id, CountdownModel countdownModel) { if (id != countdownModel.Id) { return(BadRequest()); } _context.Entry(countdownModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CountdownModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void StartSubstaction(CountdownModel counter) { _counter = counter; _substractTimer = new Timer(1000); _substractTimer.Elapsed += SubstractTime; _substractTimer.AutoReset = true; _substractTimer.Enabled = true; }
public ApplicationViewModel() { _countdownModel = new CountdownModel(); //Sets up new CVM keeping this class, so only //one instance of this is ever created. CurrentView = new CountdownViewModel(this, _countdownModel); }
public CountdownSettingsViewModel(CountdownModel countdownModel, ApplicationViewModel applicationViewModel) { _countdownModel = countdownModel; _applicationViewModel = applicationViewModel; MaxSeconds = _countdownModel.MaxSeconds; BackCommand = new RelayCommand(GoBack); ApplyCommand = new RelayCommand(ApplySettings); }
public async Task <ActionResult <CountdownModel> > PostCountdownModel(CountdownModel countdownModel) { _context.CountdownModels.Add(countdownModel); await _context.SaveChangesAsync(); Actions.DecreaseTime decreaseTime = new Actions.DecreaseTime(); decreaseTime.StartSubstaction(countdownModel); return(CreatedAtAction(nameof(GetCountdownModel), new { id = countdownModel.Id }, countdownModel)); }
public CountdownViewModel() { countdown = new CountdownModel(); timer = new AppTimer(200); timer.AfterTick += AfterTick; timerSheets = new ObservableCollection <TimerSheetViewModel>(); CreateCommand = new CountdownViewModelCreateCommand(this); OutputFilename = ConfigurationManager.AppSettings["Filename"]; System.IO.File.Create(OutputFilename); }
public CountdownViewModel(SaveList saveList) { OutputFilename = ConfigurationManager.AppSettings["Filename"]; Countdown = new CountdownModel(); timer = new AppTimer(200); timer.AfterTick += AfterTick; TimerSheets = new ObservableCollection <TimerSheetViewModel>(); CreateCommand = new DelegateCommandResolver(SaveChanged, () => CanUpdate); System.IO.File.Create(OutputFilename); DoSaveList += saveList; }
public CountdownViewModel(ApplicationViewModel applicationViewModel, CountdownModel countdownModel) { CountdownModel = countdownModel; CountdownModel.SecondsRemaining = CountdownModel.MaxSeconds; StartCountdownCommand = new RelayCommand(StartCountdown); StopCountdownCommand = new RelayCommand(StopCountdown); SettingsCommand = new RelayCommand(GoToSettings); ResetCommand = new RelayCommand(ResetTimer); _isRunning = false; isStartButtonEnabled = true; isStopButtonEnabled = true; //CountdownSettingsViewModel = new CountdownSettingsViewModel(CountdownModel, _applicationViewModel); //Initialises AVM as the one which created it //so there is always only one AVM instance to easily inform //the main window. _applicationViewModel = applicationViewModel; }