Пример #1
0
        // 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));
        }
Пример #2
0
 public DatabaseTest()
 {
     _repository = new DataRepository();
     _comment    = new VideoComment()
     {
         AuthorDisplayName = "Name",
         TextOriginal      = "Text",
         Id      = "1-1-1",
         VideoId = "2-2-2"
     };
 }
Пример #3
0
        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));
        }
Пример #4
0
        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();
            }
        }
Пример #5
0
        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));
        }