示例#1
0
        public async Task <IHttpActionResult> Put(int id, ReviewViewModelPost viewModel)
        {
            try
            {
                var review = await _reviewOperations.GetAsync(id);

                if (review == null)
                {
                    return(this.Result404("This review is not found"));
                }
                var checkRightsResult = CheckPermission(review);
                if (checkRightsResult != null)
                {
                    return(checkRightsResult);
                }

                review    = Mapper.Map <Review>(viewModel);
                review.Id = id;
                await _reviewOperations.UpdateAsync(review);

                return(await Get(id));
            }
            catch (Exception ex)
            {
                ErrorLogger.Log("CANNOT PUT REVIEW", ex);
                throw;
            }
        }
示例#2
0
        public void Update_Ok_Test()
        {
            var review    = _context.Reviews.First();
            var rndString = Guid.NewGuid().ToString();
            var date      = DateTime.Now.Date;
            var result    = _reviewOperations.UpdateAsync(new Review
            {
                Id          = review.Id,
                ActivityId  = review.ActivityId,
                DateCreated = date,
                IsChecked   = review.IsChecked,
                Text        = rndString,
                UserId      = review.UserId,
            }).Result;

            Assert.AreEqual(rndString, result.Text);
            Assert.AreEqual(review.DateCreated.Date, result.DateCreated.Date);
        }