public Score PostScore(Score score)
 {
     try
     {
         connection.Open();
         var cmd = connection.CreateCommand() as SqlCommand;
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.CommandText = "Score_PostScore";
         cmd.Parameters.Add(new SqlParameter("@earthwatcherid", score.EarthwatcherId));
         cmd.Parameters.Add(new SqlParameter("@action", score.Action));
         cmd.Parameters.Add(new SqlParameter("@points", score.Points));
         cmd.Parameters.Add(new SqlParameter("@landId", score.LandId));
         cmd.Parameters.Add(new SqlParameter("@param1", score.Param1));
         cmd.Parameters.Add(new SqlParameter("@param2", score.Param2));
         var idParameter = new SqlParameter("@ID", SqlDbType.Int) { Direction = ParameterDirection.Output };
         cmd.Parameters.Add(idParameter);
         cmd.ExecuteNonQuery();
         connection.Close();
         return score;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void Post(Score score, string username, string password)
 {
     client.Authenticator = new HttpBasicAuthenticator(username, password);
     var request = new RestRequest("scores", Method.POST) { RequestFormat = DataFormat.Json };
     request.JsonSerializer = new JsonSerializer();
     request.AddBody(score);
     
     client.ExecuteAsync<Score>(request, response =>
         Deployment.Current.Dispatcher.BeginInvoke(() =>
             ScoreAdded(response.Data, null)
             ));
 }
 public Score UpdateScore(Score score)
 {
     connection.Open();
     var cmd = connection.CreateCommand() as SqlCommand;
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.CommandText = "Score_UpdateScore";
     cmd.Parameters.Add(new SqlParameter("@earthwatcherid", score.EarthwatcherId));
     cmd.Parameters.Add(new SqlParameter("@action", score.Action));
     cmd.Parameters.Add(new SqlParameter("@points", score.Points));
     cmd.ExecuteNonQuery();
     connection.Close();
     score.Published = DateTime.UtcNow;
     return score;
 }
 public HttpResponseMessage<Score> UpdateScore(Score score, HttpRequestMessage<Score> request)
 {
     if (score.EarthwatcherId != 0 &&
         !String.IsNullOrEmpty(score.Action) &&
         score.Points != 0)
     {
         var newScore = scoreRepository.UpdateScore(score);
         var response = new HttpResponseMessage<Score>(newScore) { StatusCode = HttpStatusCode.OK };
         response.Headers.Location = new Uri(newScore.Uri, UriKind.Relative);
         return response;
     }
     else
     {
         var response = new HttpResponseMessage<Score>(null) { StatusCode = HttpStatusCode.BadRequest, ReasonPhrase = "request parameters not correct" };
         return response;
     }
 }
 public void logSlInstall()
 {
     var connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["EarthwatchersConnection"].ConnectionString;
     IScoreRepository repo = new ScoreRepository(connectionstring);
     Score s = new Score(17, ActionPoints.Action.Log.ToString(), ActionPoints.Points(ActionPoints.Action.Log), 0, 100, null, null, "SL_Install");
     repo.PostScore(s);
 }
 public void logSlInstall()
 {
     var connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["EarthwatchersConnection"].ConnectionString;
     IScoreRepository repo = new ScoreRepository(connectionstring);
     Score s = new Score();
     s.EarthwatcherId = 17;
     s.Action = ActionPoints.Action.Log.ToString();
     s.Points = ActionPoints.Points(ActionPoints.Action.Log);
     s.Published = DateTime.UtcNow;
     s.Param1 = "SL_Install";
     repo.PostScore(s);
 }
 void UpdatePoints(string action, int points)
 {
     var score = new Score(Current.Instance.Earthwatcher.Id, action, points, Current.Instance.Earthwatcher.PlayingRegion, Current.Instance.PrecisionScore);
     isScoreAdding = true;
     scoreRequest.Update(score, Current.Instance.Username, Current.Instance.Password);
 }
 void UpdatePoints(string action, int points)
 {
     var score = new Score { EarthwatcherId = Current.Instance.Earthwatcher.Id, Action = action, Points = points };
     isScoreAdding = true;
     scoreRequest.Update(score, Current.Instance.Username, Current.Instance.Password);
 }