public ResultViewModel <Track> Post(TrackEditViewModel Track) { ResultViewModel <Track> result = new ResultViewModel <Track>(); try { if (!ModelState.IsValid) { result.Message = "In Valid Model State"; } else { Track selectedTrack = trackService.Add(Track); result.Successed = true; Hub.Clients.All.TrackCount(trackService.Count()); Hub.Clients.All.TrackAdd(Track.Name); result.Data = selectedTrack; } } catch (Exception ex) { result.Successed = false; result.Message = "Semething Went Wrong"; } return(result); }
private void TrackingStopped(DateTime stopTime) { if (distance > 0) { var trackEntity = new TrackEntity { StartDate = startTime, EndDate = stopTime, // TODO: utc? Distance = distance }; _trackService.Add(trackEntity); var json = JsonConvert.SerializeObject(trackEntity); var intent = new Intent("TrackingStopped"); intent.PutExtra("TrackEntity", json); LocalBroadcastManager.SendBroadcast(intent); } isStarted = false; startTime = default(DateTime); distance = 0; currentModel = null; textViewTrackingCoordinates.Text = string.Empty; textViewTrackingDuration.Text = string.Empty; textViewTrackingStarted.Text = string.Empty; textViewTrackingDistance.Text = string.Empty; }