public async Task<IHttpActionResult> PutTweet(int id, Tweet tweet)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != tweet.Id)
            {
                return BadRequest();
            }

            db.Entry(tweet).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TweetExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Пример #2
0
 private static ProjectTeddy.Core.EntityFramework.Tweet InviTweetToPTTweet(ITweet t)
 {
     ProjectTeddy.Core.EntityFramework.Tweet ptTweet = new ProjectTeddy.Core.EntityFramework.Tweet();
     if (t.Coordinates != null)
     {
         ptTweet.Coordinates = t.Coordinates.Longitude.ToString() + ","
                               + t.Coordinates.Latitude.ToString();
     }
     ptTweet.CreatedOn = t.CreatedAt;
     ptTweet.ReplyToId = t.InReplyToUserIdStr;
     ptTweet.Text      = t.Text;
     return(ptTweet);
 }
Пример #3
0
 private static ProjectTeddy.Core.EntityFramework.Tweet InviTweetToPTTweet(ITweet t)
 {
     ProjectTeddy.Core.EntityFramework.Tweet ptTweet = new ProjectTeddy.Core.EntityFramework.Tweet();
     if (t.Coordinates != null)
     {
         ptTweet.Coordinates = t.Coordinates.Longitude.ToString() + ","
             + t.Coordinates.Latitude.ToString();
     }
     ptTweet.CreatedOn = t.CreatedAt;
     ptTweet.ReplyToId = t.InReplyToUserIdStr;
     ptTweet.Text = t.Text;
     return ptTweet;
 }
        public async Task<IHttpActionResult> PostTweet(Tweet tweet)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Tweets.Add(tweet);
            await db.SaveChangesAsync();

            return CreatedAtRoute("DefaultApi", new { id = tweet.Id }, tweet);
        }