Example #1
0
        public IHttpActionResult PutUser(int id, User user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #2
0
 public void CreateTweet(Tweet tweet)
 {
     if (tweet == null)
     {
         throw new NotImplementedException("Tweet not initializaed");
     }
     else
     {
         tweet.CreateDate = DateTime.Now;
         db.Tweets.Add(tweet);
         db.SaveChanges();
     }
 }