internal async Task <bool> postRequest(Qso qso, string route) { bool result = false; try { LogEntry logEntry = Mapper.Map <LogEntry>(qso); LogEntryRequest request = new LogEntryRequest() { LogEntry = logEntry }; var json = JsonConvert.SerializeObject(request); using (var client = new HttpClient()) { string url = String.Format("{0}{1}", serviceUrl, route); var headerValue = new MediaTypeWithQualityHeaderValue("text/json"); client.DefaultRequestHeaders.Accept.Add(headerValue); HttpResponseMessage response = await client.PostAsync(url, new StringContent(json, Encoding.UTF8, "text/json")); if (response.IsSuccessStatusCode) { result = true; } } } catch { result = false; } return(result); }
protected void on_EntryCanceled_Command(object obj) { window = obj as Window; window.Close(); qso = new Qso(); MessageSink.MessageBus.GetEvent <EntryCompleteNotification>().Publish(new object()); }
private void onEditQso_Command(object commandParameter) { Qso qso = commandParameter as Qso; if (qso != null) { MessageSink.MessageBus.GetEvent <EditEntryNotification>().Publish(qso.Id); } }
private LogEntryRequest mapQsoToLogEntryRequest(Qso qso) { LogEntry logEntry = Mapper.Map <LogEntry>(qso); return(new LogEntryRequest() { LogEntry = logEntry }); }
protected virtual void onEditEntryNotification(Guid details) { qsoType = QsoType.ExistingQso; NotifyPropertyChanged("text"); qso = service.GetQsoBy(details); string msg; ErrorMessage = String.Empty; if (!qsoIsValid(out msg)) { ErrorMessage = msg; } notifyAllPropertiesChanged(); onKeyUp_Command(Callsign); }
public void Add(Qso qso) { mutex.WaitOne(); try { qsos.Add(qso); saveLog(); } catch { } finally { mutex.ReleaseMutex(); } }
public void Remove(Qso qso) { mutex.WaitOne(); try { int i = qsos.FindIndex(x => x.Id == qso.Id); qsos.RemoveAt(i); saveLog(); } catch { } finally { mutex.ReleaseMutex(); } }
protected virtual void onNewEntryNotification() { qsoType = QsoType.NewQso; notifyAllPropertiesChanged(); NotifyPropertyChanged("text"); qso = new Qso(); DateTime = DateTime.UtcNow; qso.Transmitter = transmitter; qso.Receiver = receiver; // check dupe view for callsign MessageSink.MessageBus.GetEvent <DataDictionaryRequest>().Publish(new object()); // get rig state MessageSink.MessageBus.GetEvent <TransceiverStateRequest>().Publish(new object()); // ErrorMessage = String.Empty; notifyAllPropertiesChanged(); onKeyUp_Command(Callsign); }
public async Task <IActionResult> PostQso([FromRoute] int stationId, [FromBody] Qso qso) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!StationExists(stationId)) { return(NotFound()); } else { qso.StationId = stationId; _context.Log.Add(qso); await _context.SaveChangesAsync(); return(CreatedAtAction("GetQso", "Public", new { id = qso.QsoId }, qso)); } }
public async Task <IActionResult> PostQso([FromRoute] int stationId, [FromBody] AdifRow adifRow, [FromRoute] int minutesAccept = 10) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!StationExists(stationId)) { return(NotFound()); } else { try { Station station = _context.Station.Find(stationId); Qso[] duplicates = _context.SearchDuplicates(station, adifRow, minutesAccept) ?? new Qso[0]; if (duplicates.Length > 0) { var duplicateQso = duplicates.First(); return(RedirectToAction("GetQso", "Public", new { duplicateQso.StationId, duplicateQso.QsoId })); } else { Qso qso = Converters.Convert(adifRow, station); _context.Log.Add(qso); await _context.SaveChangesAsync(); return(CreatedAtRoute(new { id = qso.QsoId }, qso)); } } catch (Exception exc) { _logger.LogError(exc.Message, null); return(BadRequest(exc.Message)); } } }
public async Task <IActionResult> PutQso([FromRoute] int stationId, [FromRoute] int qsoId, [FromBody] Qso qso) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (qsoId != qso.QsoId) { return(BadRequest()); } _context.Entry(qso).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QsoExists(qsoId)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <bool> Update(Qso qso) { return(await Task.Run(() => false)); }
public async Task <bool> Insert(Qso qso) { return(await Task.Run(() => false)); }
public void AddQso(Qso qso) { repository.Add(qso); }
public void UpdateQso(Qso qso) { repository.Update(qso); }
public async Task <bool> Update(Qso qso) { return(await postRequest(qso, "update")); }
public async Task <bool> Update(Qso qso) { LogEntryRequest logEntryRequest = mapQsoToLogEntryRequest(qso); return(await postQso(logEntryRequest, "update")); }
public async Task <bool> Insert(Qso qso) { LogEntryRequest logEntryRequest = mapQsoToLogEntryRequest(qso); return(await postQso(logEntryRequest, "insert")); }
public async Task <bool> Update(Qso qso) { return(false); }
public async Task <bool> Insert(Qso qso) { return(false); }
public async Task <bool> Insert(Qso qso) { return(await postRequest(qso, "insert")); }
public void Remove(Qso qso) { repository.Remove(qso); }