예제 #1
0
 public ResultModel Create(Review review)
 {
     try
     {
         int id = _reviewService.CreateReview(review, _settingsService.GetSettings <bool>(nameof(Setting.ReviewCreatedNotification)));
         return(new ResultModel(true, id));
     }
     catch (Exception e)
     {
         _logService.LogError(e);
         return(new ResultModel(e));
     }
 }
예제 #2
0
        public async Task <IActionResult> Review(UserReviewRequestModel userReviewRequestModel)
        {
            userReviewRequestModel.UserId = Convert.ToInt32(HttpContext.User.Claims.FirstOrDefault(u => u.Type == ClaimTypes.NameIdentifier).Value);
            var createReview = await _reviewService.CreateReview(userReviewRequestModel);

            return(LocalRedirect("~/Movies/Details/" + userReviewRequestModel.MovieId));
        }
예제 #3
0
        public async Task <ActionResult <Review> > PostReview(Review review)
        {
            _reviewService.CreateReview(review);
            await _reviewService.SaveChanges();

            return(CreatedAtAction("GetReview", new { id = review.Id }, review));
        }
예제 #4
0
 public ActionResult Create(ReviewModel review)
 {
     if (ModelState.IsValid)
     {
         reviewService.CreateReview(mapper.Map <ReviewDTO>(review));
     }
     return(Redirect("/Review/Index"));
 }
예제 #5
0
        public async Task <IActionResult> AddReview(Review review)
        {
            review.ReviewDate = DateTime.Now;
            var user = _identityService.Get(HttpContext.User);

            await _reviewService.CreateReview(user, review);

            return(RedirectToAction("Index", "Review"));
        }
예제 #6
0
        public IActionResult CreateReview([FromBody] CreateReviewDto createReviewDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            return(Ok(_reviewService.CreateReview(createReviewDto)));
        }
예제 #7
0
        public async Task <IActionResult> PostReview(ReviewModel review)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await reviewService.CreateReview(review);

            return(Ok());
        }
예제 #8
0
 public ActionResult CreateReview(Review review)
 {
     try
     {
         _reviewService.CreateReview(review, _settingsService.GetSettings <bool>(nameof(Setting.ReviewCreatedNotification)));
         return(Json(ResultModel.Success));
     }
     catch (Exception e)
     {
         _logService.LogError(e);
         return(Json(new ResultModel(e)));
     }
 }
예제 #9
0
        public ActionResult CreateReview(CreateReviewViewModel postViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("CreateReview", postViewModel));
            }

            var review = _mapper.Map <Review>(postViewModel);

            _reviewService.CreateReview(review, postViewModel.RestaurantPublicId);

            return(RedirectToAction("ListRestaurants", "Restaurant"));
        }
예제 #10
0
        public IActionResult Post([FromBody] CreateReviewViewModel createReviewViewModel)
        {
            var reviewDto     = Mapper.Map <ReviewDto>(createReviewViewModel);
            var createdReview = _reviewService.CreateReview(reviewDto);

            createReviewViewModel = Mapper.Map <CreateReviewViewModel>(createdReview);

            if (createReviewViewModel == null)
            {
                return(BadRequest());
            }

            return(Ok(createReviewViewModel));
        }
        public async Task <IActionResult> OnPostReviewAsync()
        {
            NewReview.Reviewer = await _userManager.GetUserAsync(User);

            NewReview.Reviewee = await _userManager.FindByIdAsync(NewReview.RevieweeId.ToString());

            NewReview.Ride       = _rideService.GetRide(NewReview.RideId);
            NewReview.ReviewDate = DateTime.Now;
            NewReview.RideId     = RideId;
            if (!ModelState.IsValid)
            {
                return(RedirectToPage("Reviews"));
            }
            _reviewService.CreateReview(NewReview);
            return(RedirectToPage("Reviews", new { id = NewReview.RevieweeId }));
        }
예제 #12
0
        public async Task <int> CreateReview([FromForm] string ProductID, [FromForm] string Review)
        {
            string UserID = HttpContext.Session.GetString("UserID");

            if (UserID != null)
            {
                Users user = await _userService.GetUserByUserID(UserID);

                Products product = await _productService.GetProductByProductID(ProductID);

                return(await _reviewService.CreateReview(user, product, Review));
            }
            else
            {
                return(0);
            }
        }
예제 #13
0
        public async Task <IActionResult> Create([FromBody] ReviewsCreate model)
        {
            List <String> messages = new List <String>();

            var product = await _productService.GetById(model.ProductId);

            var user = await _userService.GetByUsername(model.Username);

            if (product == null)
            {
                messages.Add("Product not found!");
            }

            if (user == null)
            {
                messages.Add("User not found!");
            }
            else
            {
                model.UserID = user.ID;
            }

            if (model.Rating <= 0 && model.Rating > 10)
            {
                messages.Add("Rating must be in range 0-10");
            }

            if (messages.Any())
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new
                {
                    ErrorCode = StatusCodes.Status500InternalServerError,
                    ErrorMessages = string.Join(",", messages)
                }));
            }

            var reviewId = await _reviewService.CreateReview(model);

            return(Ok(new
            {
                resultId = reviewId,
                desciption = reviewId > 0 ? "Successfully created." : "Could not create this reivew."
            }));
        }
        public async Task <IActionResult> CreateReview([FromQuery] int productId, [FromBody] CreateProductReviewResource resource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var userInput = _mapper.Map <CreateProductReviewResource, ProductReview>(resource);
                userInput.AddedBy = _user.Name + " " + _user.Surname;
                var review = await _reviewService.CreateReview(productId, _user.Id, userInput);

                return(Ok(new { message = "Rəy qeydə alındı" }));
            }
            catch (HttpException e)
            {
                return(StatusCode(e.StatusCode, e.Response));
            }
        }
예제 #15
0
        public IActionResult Post([FromBody] ReviewDto dto)
        {
            //automatic .NET Core ModelState validation: all ModelState errors are automatically added to the response as a 400 BadRequest

            try
            {
                var review = dto.ToEntity();
                _reviewService.CreateReview(review);
            }
            catch
            {
                return(BadRequest(new ModelErrorDto()
                {
                    Errors = new List <string> {
                        "An unknown error occured."
                    }
                }));
            }
            return(Ok());
        }
예제 #16
0
        public ActionResult Index(Review review)
        {
            var mapper = MapperConfigWeb.GetConfigToDTO().CreateMapper();

            try
            {
                review.Id   = Guid.NewGuid().ToString();
                review.Date = DateTime.UtcNow;
                var reviewDto = mapper.Map <ReviewDTO>(review);
                _reviewService.CreateReview(reviewDto);
            }
            catch (ValidationException ex)
            {
                ModelState.AddModelError(ex.Property, ex.Message);
            }
            mapper = MapperConfigWeb.GetConfigFromDTO().CreateMapper();
            var model = mapper.Map <IEnumerable <Review> >(_reviewService.GetReviews());

            return(PartialView("Partials/ReviewList", model));
        }
예제 #17
0
        public async Task <IActionResult> CreateReview([FromBody] ReviewForUserCreateDto input)
        {
            if (ModelState.IsValid)
            {
                var userId = GetUserId();
                if (userId == "error")
                {
                    return(Unauthorized(new { message = "unauthorized" }));
                }
                input.ApplicationUserId = userId;
                input.Date = DateTime.Now;
                var review = _mapper.Map <Review>(input);
                var result = await _reviewService.CreateReview(review);

                if (result)
                {
                    return(Ok(new { message = "Review của bạn được đăng thành công !" }));
                }
            }
            return(BadRequest(new { message = "Invalid review" }));
        }
예제 #18
0
        public IActionResult Create(Guid bookId, [FromBody] CreateReviewModel model)
        {
            var newlyCreated = ReviewService.CreateReview(bookId, model);

            return(CreatedAtRoute("GetReview", new { bookid = bookId, reviewid = newlyCreated }, newlyCreated));
        }
예제 #19
0
 public async Task CreateReviewWithNullArgument_ThrowsException()
 {
     await Assert.ThrowsAsync <ArgumentNullException>(() => reviewService.CreateReview(null));
 }
        public async Task <IActionResult> CreateReview([FromBody] ReviewCreationDto reviewCreationDto)
        {
            string email = User.Identity.Name;

            return(Ok(await _reviewService.CreateReview(reviewCreationDto, email)));
        }
예제 #21
0
 public ActionResult AddReview(Review review)
 {
     _reviewService.CreateReview(review, false);
     return(Json(ResultModel.Success));
 }
예제 #22
0
        private async void AddReviewButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(ReviewPriceTextBox.Text) || !IsMoney(ReviewPriceTextBox.Text))
                {
                    MessageBox.Show("Няма цена.");
                    return;
                }

                if (string.IsNullOrEmpty(MounthsCombo.Text))
                {
                    MessageBox.Show("Избери месеци");
                    return;
                }

                short contributionsCount = GetContributionsCount();

                if (contributionsCount == -1)
                {
                    MessageBox.Show("Избери Вноски");
                    return;
                }
                if (string.IsNullOrEmpty(InsuranceAngecyCombo.Text))
                {
                    MessageBox.Show("Попълнете застрахователна агенция!");
                    return;
                }
                if (InsuranceAngecyCombo.Text.Length > 60)
                {
                    MessageBox.Show("Твърде дълго име на застрахователна ангеция!");
                    return;
                }

                short mounthsCount = short.Parse(MounthsCombo.Text);

                CreateReviewInputModel createReviewModel = new CreateReviewInputModel
                {
                    ContributionCount = contributionsCount,
                    MonthCount        = mounthsCount,
                    Price             = double.Parse(ReviewPriceTextBox.Text),
                    ReviewedDate      = ReviewStartDate.Value.ToString("dd.MM.yyyy"),
                    ReviewHeader      = reviewService.GenerateReviewHeader(ReviewStartDate.Value),
                    MotorcycleDataId  = GlobalVariables.CurrentBikeId,
                    InsuranceAgency   = InsuranceAngecyCombo.Text,
                    EndDate           = reviewService.GenerateEndDate(ReviewStartDate.Value, mounthsCount).ToString("dd.MM.yyyy"),
                };

                reviewService.CreateReview(createReviewModel);

                await Information("Успешно добавена нова застраховка", InformationType.Success);

                GenerateContributionInfo(createReviewModel);
                ClearReviewFileds();
            }
            catch (Exception ex)
            {
                logger.LogExceptionText(ex.ToString(), "Batkooo sefte pisha neshto v tiq raboti eiiiiiii mainaaaaaaa");
                await Information("Нещо се обърка. Няма добавена застраховка", InformationType.Error);
            }
        }
예제 #23
0
        //[Authorize(Roles = "Admin, Vendor")]
        public async Task <IActionResult> CreateReview([FromBody] CreateReviewBlogRequest request)
        {
            var result = await reviewService.CreateReview(request);

            return(StatusCode((int)result.Code, result.Value));
        }