Example #1
0
        public HttpResponseMessage<News> PostNews(News news, HttpRequestMessage<News> request)
        {
            if (news.EarthwatcherId != 0 && news.NewsItem!= String.Empty)
                newsRepository.PostNews(news);

            return null;
        }
 public News PostNews(News news)
 {
     connection.Open();
     var cmd = connection.CreateCommand() as SqlCommand;
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.CommandText = "News_PostNews";
     
     cmd.Parameters.Add(new SqlParameter("@userid", news.EarthwatcherId));
     cmd.Parameters.Add(new SqlParameter("@NewsItem", news.NewsItem));
     cmd.Parameters.Add(new SqlParameter("@Published", DateTime.Now.ToUniversalTime()));
     cmd.Parameters.Add(new SqlParameter("@shape", SqlGeography.STGeomFromText(new SqlChars(news.Wkt), 4326)) { UdtTypeName = "Geography" });
     var idParameter = new SqlParameter("@ID", SqlDbType.Int) {Direction = ParameterDirection.Output};
     cmd.Parameters.Add(idParameter);
     cmd.ExecuteNonQuery();
     connection.Close();
     return news;
 }
 public NewsControl(News news)
 {
     InitializeComponent();
     this.news = news;
     Init();
 }