Beispiel #1
0
        private void StartPostComment()
        {
            if (Current.Instance.Earthwatcher == null)
            {
                var warning = new WarningScreen(Labels.Comments4);
                warning.Show();
                return;
            }

            if (txtComment.Text.Trim().Equals(""))
            {
                return;
            }

            var comment = new Earthwatchers.Models.Comment
            {
                FullName       = Current.Instance.Earthwatcher.FullName,
                Published      = DateTime.UtcNow,
                UserName       = Current.Instance.Username,
                EarthwatcherId = Current.Instance.Earthwatcher.Id,
                LandId         = landId,
                UserComment    = txtComment.Text,
            };

            commentRequests.Post(comment, Current.Instance.Username, Current.Instance.Password);

            txtComment.Text = "";

            comment.Published = DateTime.UtcNow;
            comments.Insert(0, comment);
        }
        private void StartPostComment()
        {
            if (Current.Instance.Earthwatcher == null)
            {
                var warning = new WarningScreen("You are not logged in");
                warning.Show();
                return;
            }

            if (txtComment.Text.Trim().Equals(""))
                return;

            var comment = new Earthwatchers.Models.Comment
            {
                FullName = Current.Instance.Earthwatcher.FullName,
                Published = DateTime.Now,
                UserName = Current.Instance.Username,
                EarthwatcherId = Current.Instance.Earthwatcher.Id,
                LandId = landId,
                UserComment = txtComment.Text,               
            };

            commentRequests.Post(comment, Current.Instance.Username,Current.Instance.Password);

            txtComment.Text = "";

            comment.Published = DateTime.Now;
            comments.Insert(0, comment);
        }
 public void Post(Comment comment, string username, string password)
 {
     client.Authenticator = new HttpBasicAuthenticator(username, password);
     var request = new RestRequest("comments", Method.POST) { RequestFormat = DataFormat.Json };
     request.JsonSerializer = new JsonSerializer();
     request.AddBody(comment);
     client.ExecuteAsync(request, response => {});
 }
 public HttpResponseMessage<Comment> DeleteComment(Comment comment, HttpRequestMessage<Comment> request)
 {
     if (comment.Id != 0)
     {
         commentRepository.DeleteComment(comment.Id);
         return new HttpResponseMessage<Comment>(null) { StatusCode = HttpStatusCode.OK };
     }
     return new HttpResponseMessage<Comment>(null) { StatusCode = HttpStatusCode.NotFound };
 }
 public HttpResponseMessage<Comment> PostComment(Comment comment, HttpRequestMessage<Comment> request)
 {
     if (comment.EarthwatcherId != 0 && comment.LandId != 0 & comment.UserComment != null)
     {
         var newcomment=commentRepository.PostComment(comment);
         var response = new HttpResponseMessage<Comment>(newcomment) { StatusCode = HttpStatusCode.Created };
         response.Headers.Location = new Uri(newcomment.Uri, UriKind.Relative);
         return response;
     }
     return null;
 }
        public Comment PostComment(Comment comment)
        {
            connection.Open();
            var cmd = connection.CreateCommand() as SqlCommand;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "Comments_PostComment";

            cmd.Parameters.Add(new SqlParameter("@userid", comment.EarthwatcherId));
            cmd.Parameters.Add(new SqlParameter("@landid", comment.LandId));
            cmd.Parameters.Add(new SqlParameter("@Comment", comment.UserComment));
            cmd.Parameters.Add(new SqlParameter("@Published", DateTime.UtcNow));
            var idParameter = new SqlParameter("@ID", SqlDbType.Int) {Direction = ParameterDirection.Output};
            cmd.Parameters.Add(idParameter);
            cmd.ExecuteNonQuery();
            connection.Close();
            return comment;
        }