示例#1
0
 public ActionResult <Review> Create([FromBody] Review newReview)
 {
     try
     {
         return(Ok(_service.Create(newReview)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
示例#2
0
        public async Task <ActionResult <Review> > Create([FromBody] Review newReview)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                newReview.CreatorId = userInfo.Id;
                return(Ok(_service.Create(newReview)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
示例#3
0
        public async Task <ActionResult <Review> > Post([FromBody] Review newReview)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                newReview.OwnerId = userInfo.Id;
                Review created = _revserv.Create(newReview);
                created.Owner = userInfo;
                return(Ok(created));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
        public void Create_IncreasesCount()
        {
            // Arrange
            var context        = this.ServiceProvider.GetRequiredService <WmipDbContext>();
            var reviewsService = new ReviewsService(context);
            var creationInfo   = new CreateReviewDto()
            {
                Title = "rev"
            };

            // Act
            reviewsService.Create(creationInfo);

            //Assert
            Assert.Single(context.Reviews);
        }
示例#5
0
        public IActionResult CreateReviewOfTape(
            [FromRoute] int friendId,
            [FromRoute] int tapeId,
            [FromBody] ReviewInputModel inputModel
            )
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var review = new Review
            {
                FriendId = friendId,
                TapeId   = tapeId,
                Rating   = inputModel.Rating
            };

            ReviewsService.Create(review);
            return(CreatedAtAction(
                       nameof(GetReviewOfTape),
                       new { friendId = review.FriendId, tapeId = review.TapeId },
                       review.ToDto()));
        }