// PUT api/Comment/5 public IHttpActionResult PutVideoComment(int id, VideoComment videocomment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != videocomment.Id) { return(BadRequest()); } db.Entry(videocomment).State = System.Data.Entity.EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!VideoCommentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public DatabaseTest() { _repository = new DataRepository(); _comment = new VideoComment() { AuthorDisplayName = "Name", TextOriginal = "Text", Id = "1-1-1", VideoId = "2-2-2" }; }
public IHttpActionResult PostVideoComment(VideoComment videocomment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.VideoComments.Add(videocomment); db.SaveChanges(); return(CreatedAtRoute("VideoCommentApi", new { id = videocomment.Id }, videocomment)); }
public void SaveComment(VideoComment comment) { if (!comment.IsTransient()) { return; } using (IDataGateway dataGateway = this.dataGatewayProvider.GetDataGateway()) { comment.Id = dataGateway.Connection.Query <int>(@"insert into videocomment(vkid, creatorid, posteddate, year, month, week, day, hour, minute, second, vkgroupid, vkvideoid) values (@VkId, @CreatorId, @PostedDate, @Year, @Month, @Week, @Day, @Hour, @Minute, @Second, @VkGroupId, @VkVideoId) RETURNING id", comment).First(); } }
public IHttpActionResult DeleteVideoComment(int id) { VideoComment videocomment = db.VideoComments.Find(id); if (videocomment == null) { return(NotFound()); } db.VideoComments.Remove(videocomment); db.SaveChanges(); return(Ok(videocomment)); }