Beispiel #1
0
        public ActionResult Create([FromBody] Review review)
        {
            Guid userId = Guid.Parse(User.Identity.Name);

            _reviewService.Create(review, userId);
            return(Ok());
        }
Beispiel #2
0
        public async Task <IActionResult> CreateReview(ReviewCreateRequest request)
        {
            if (ModelState.IsValid)
            {
                var result = await _reviewService.Create(request);

                if (result.IsSuccessed)
                {
                    var message = new EmailMessage
                    {
                        To      = request.Email,
                        Subject = "Thank for review",
                        Content = "Thank you for reaching out to me. I really enjoyed my stay in your apartment and will make sure to come back next year.",
                    };
                    await _emailService.SendEmail(message);

                    return(RedirectToAction("detail", new { productId = request.ProductId }));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, result.Message);
                    return(View(request));
                }
            }
            return(View(request));
        }
Beispiel #3
0
        public async Task <IActionResult> Create(ReviewForCreationDto reviewForCreation)
        {
            await _reviewValidatorService.ValidateForCreation(reviewForCreation);

            await _reviewService.Create(reviewForCreation);

            return(Ok());
        }
Beispiel #4
0
        public void CreateReview()
        {
            var token  = InstanceFactory.AuthorizedUserId();
            var course = InstanceFactory.Course();

            course = _courseService.Create(course, token);
            var courseTask = InstanceFactory.CourseTask(token, course.Id);

            courseTask = _courseTaskService.Create(courseTask, token);
            var solution = InstanceFactory.Solution(token, courseTask.Id);

            solution = _solutionService.Create(solution, token);

            var review        = InstanceFactory.Review(token, solution.Id, courseTask);
            var createdReview = _reviewService.Create(review, token);

            Assert.IsNotNull(createdReview);
        }
Beispiel #5
0
        public IHttpActionResult Post(CreatePreviewViewModel newModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _previewSevice.Create(_mapper.Map <Review>(newModel));
            return(Ok());
        }
Beispiel #6
0
        public IActionResult Create([FromBody] PostReviewDTO postReview)
        {
            var userId    = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var isCreated = _reviewService.Create(userId, postReview);

            if (isCreated)
            {
                return(Ok());
            }
            return(BadRequest());
        }
Beispiel #7
0
 public IActionResult Create([FromBody] ReviewDto dto)
 {
     try {
         var review = _svc.Create(_mapper.Map <Review>(dto));
         return(Ok(_mapper.Map <ReviewDto>(review)));
     } catch (PleyNotFoundException ex) {
         return(NotFound(new ErrorResponse(ex.Message)));
     } catch (Exception ex) {
         return(BadRequest(new ErrorResponse(ex.Message)));
     }
 }
Beispiel #8
0
        public IActionResult PostReview([FromBody] Review entity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Review review = _service.Create(entity);

            return(Ok(review));
        }
        public Review Create(int rating, string comment, Customer customer, Product product)
        {
            Review newReview = new Review()
            {
                CustomerId = customer.CustomerId,
                ProductId  = product.ProductId,
                Rating     = rating,
                Comment    = comment
            };

            _service.Create(newReview);

            return(newReview);
        }
        public async Task <IActionResult> Create(ReviewCreateRequest request)
        {
            if (ModelState.IsValid == false)
            {
                return(BadRequest(ModelState));
            }
            var result = await _reviewService.Create(request);

            if (result.IsSuccessed == false)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
Beispiel #11
0
        public async Task <IActionResult> AddReview(Review review, int?productid, int yildiz = 1)
        {
            var user = await _userManager.GetUserAsync(User);

            review.UserId       = _userManager.GetUserId(User);
            review.UserFullName = user.FullName;
            review.Date         = DateTime.Now;
            review.Star         = yildiz;

            if (_reviewService.Create(review) > 0)
            {
                return(Json(new { result = true }, new Newtonsoft.Json.JsonSerializerSettings()));
            }

            return(Json(new { result = false }, new Newtonsoft.Json.JsonSerializerSettings()));
        }
        public ActionResult Create(CreateReviewsViewModel requestedViewModel)
        {
            if (ModelState.IsValid)
            {
                var profile = ProfileService.GetById(User.Identity.AdminId);

                ReviewService.Create(profile.ProfileId, requestedViewModel.Description, requestedViewModel.Title, requestedViewModel.Url, requestedViewModel.Picture);
                ProfileService.AddActivity(profile.ProfileId, "CreatedAReview");
                return(View("Created", new CreatedReviewsViewModel {
                    MenuKey = "reviews"
                }));
            }

            requestedViewModel.MenuKey = "reviews";
            return(View(requestedViewModel));
        }
Beispiel #13
0
        public async Task <int> AddUserReviewAsync(ReviewDto review)
        {
            using (var uow = UnitOfWorkProvider.Create())
            {
                if (await userService.GetAsync(review.ReviewedUserID) == null)
                {
                    throw new ArgumentException("User does not exist.");
                }

                var res  = reviewService.Create(review);
                var user = await userService.GetAsync(review.ReviewedUserID);

                review.ReviewedUser = user;
                await uow.Commit();

                return(res.Id);
            }
        }
Beispiel #14
0
 public async Task <IActionResult> Create([FromForm] CreateOrUpdateReviewModel model)
 {
     try
     {
         CreateOrUpdateReviewRequestModel serviceModel = new CreateOrUpdateReviewRequestModel()
         {
             Image = model.Image.OpenReadStream(),
             Stars = model.Stars,
             Text  = model.Text,
             Title = model.Title
         };
         return(CreatedAtRoute("", await _reviewService.Create(this.GetUserIdFromToken(), serviceModel)));
     }
     catch (Exception exception)
     {
         return(this.HandleExceptionToUserAndLogIfExceptionIsUnexpected(exception));
     }
 }
        public async Task <IActionResult> Create(CreateReviewBindingModel model, string city, string restaurant)
        {
            var restaurantFromDbServiceModel = await restaurantService.GetRestaurantByNameAndCity(city, restaurant);

            var userId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            ReviewServiceModel reviewServiceModel = AutoMapper.Mapper.Map <ReviewServiceModel>(model);

            reviewServiceModel.RestaurantId = restaurantFromDbServiceModel.Id;
            reviewServiceModel.UserId       = userId;
            reviewServiceModel.Date         = DateTime.Now;

            await reviewsService.Create(reviewServiceModel);

            var newRestaurantAverageRating = await restaurantService.GetAverageRate(restaurantFromDbServiceModel);

            await restaurantService.SetNewRating(restaurantFromDbServiceModel.Id, newRestaurantAverageRating);

            return(this.Redirect($"/Restaurants/{city}/{restaurant}"));
        }
Beispiel #16
0
        public async Task ShouldCreateReview()
        {
            CreateOrUpdateReviewRequestModel model = new CreateOrUpdateReviewRequestModel()
            {
                Image = new MemoryStream(),
                Text  = "TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT ",
                Title = "TITLE",
                Stars = 1
            };

            _fileUploadUtilsMock.UploadImage(Arg.Any <Stream>()).Returns(new FileDTO()
            {
                FileName = "FILENAME", FilePath = "FILEPATH"
            });

            Exception exception = await Record.ExceptionAsync(() => _reviewService.Create(Guid.NewGuid().ToString(), model));

            Assert.Null(exception);
            await _reviewRepositoryMock.Received(1).Create(Arg.Any <Review>());

            await _reviewRepositoryMock.Received(1).Save();
        }
        public void RatePage(RatingDto ratingData)
        {
            ContentReference reviewPageReference;

            if (ContentReference.TryParse(ratingData.ContentId, out reviewPageReference))
            {
                var review = new ReviewModel
                {
                    Rating                 = ratingData.Rating ? 1 : -1,
                    ReviewText             = ratingData.Comment,
                    ReviewOwnerContentLink = reviewPageReference
                };

                _reviewService.Create(review);

                AddCookie(ratingData.ContentId);

                SendNotificationEmail();
            }
            else
            {
                _logger.Log(Level.Error, $"Error parsing content reference {ratingData.ContentId}");
            }
        }
Beispiel #18
0
        public async Task <IActionResult> Create(CreateReviewViewModel model)
        {
            await _reviewService.Create(model);

            return(RedirectToAction("Index", "Home"));
        }
Beispiel #19
0
 protected override void ExecuteCommand()
 {
     reviewService.Create(Model);
 }
Beispiel #20
0
        public IActionResult Post([FromBody] Review review)
        {
            var newReview = _reviewService.Create(review);

            return(Ok(newReview));
        }
Beispiel #21
0
 public ActionResult <OutputDtoQueryReview> Post(int uservId, int itemId,
                                                 [FromBody] InputDtoAddReview inputDtoAddReview)
 {
     return(Ok(_reviewService.Create(uservId, itemId, inputDtoAddReview)));
 }
Beispiel #22
0
 public ActionResult Post([FromBody] Review reviewData)
 {
     reviewService.Create(reviewData);
     return(Ok());
 }