public void addComment(Comment comment) { if (IDC == 0) { Comments = new List<Comment>(); } Comments.Add(comment); IDC++; }
// POST api/comment public HttpResponseMessage Post(Comment comment) { //User u = db.Users.Where( //(p) => p.UserName.ToLower() == comment.UserName.ToLower()).First<User>(); //db.Users.Remove(u); //u.addComment(comment); //db.Entry(u).State = EntityState.Modified; //db.Users.Add(u); db.Comments.Add(comment); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.NotFound); } return Request.CreateResponse(HttpStatusCode.OK); }