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);
        }
Exemplo n.º 2
0
 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);
            }
        }
Exemplo n.º 4
0
        private LogEntryRequest mapQsoToLogEntryRequest(Qso qso)
        {
            LogEntry logEntry = Mapper.Map <LogEntry>(qso);

            return(new LogEntryRequest()
            {
                LogEntry = logEntry
            });
        }
Exemplo n.º 5
0
        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();
     }
 }
Exemplo n.º 8
0
 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);
 }
Exemplo n.º 9
0
        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));
            }
        }
Exemplo n.º 10
0
        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));
                }
            }
        }
Exemplo n.º 11
0
        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));
 }
Exemplo n.º 14
0
 public void AddQso(Qso qso)
 {
     repository.Add(qso);
 }
Exemplo n.º 15
0
 public void UpdateQso(Qso qso)
 {
     repository.Update(qso);
 }
Exemplo n.º 16
0
 public async Task <bool> Update(Qso qso)
 {
     return(await postRequest(qso, "update"));
 }
Exemplo n.º 17
0
        public async Task <bool> Update(Qso qso)
        {
            LogEntryRequest logEntryRequest = mapQsoToLogEntryRequest(qso);

            return(await postQso(logEntryRequest, "update"));
        }
Exemplo n.º 18
0
        public async Task <bool> Insert(Qso qso)
        {
            LogEntryRequest logEntryRequest = mapQsoToLogEntryRequest(qso);

            return(await postQso(logEntryRequest, "insert"));
        }
Exemplo n.º 19
0
 public async Task <bool> Update(Qso qso)
 {
     return(false);
 }
Exemplo n.º 20
0
 public async Task <bool> Insert(Qso qso)
 {
     return(false);
 }
Exemplo n.º 21
0
 public async Task <bool> Insert(Qso qso)
 {
     return(await postRequest(qso, "insert"));
 }
Exemplo n.º 22
0
 public void Remove(Qso qso)
 {
     repository.Remove(qso);
 }