Example #1
0
        public void Add_Ok_Test()
        {
            var user      = _context.Users.First();
            var activity  = _context.Activities.First();
            var rndString = Guid.NewGuid().ToString();
            var date      = DateTime.Now.Date;
            var result    = _reviewOperations.AddAsync(new Review
            {
                ActivityId  = activity.Id,
                DateCreated = date,
                IsChecked   = false,
                Text        = rndString,
                UserId      = user.Id
            }).Result;

            Assert.AreEqual(rndString, result.Text);
            Assert.AreEqual(date, result.DateCreated.Date);
        }
Example #2
0
        public async Task <IHttpActionResult> Post(ReviewViewModelPost postViewModel)
        {
            try
            {
                var review = Mapper.Map <Review>(postViewModel);
                var user   = await _userOperations.GetAsync(User.Identity.Name);

                review.UserId = user.Id;
                var result = await _reviewOperations.AddAsync(review);

                return(await Get(result.Id));
            }
            catch (Exception ex)
            {
                ErrorLogger.Log("CANNOT POST REVIEW", ex);
                throw;
            }
        }