Example #1
0
        public async Task <ActionResult> AddReviewPost([Bind(Include = "ReviewRate, PublishingId, Description", Prefix = "PublishingReview")]
                                                       PublishingReview publishingReview, string returnUrl)
        {
            if (User.Identity.IsAuthenticated)
            {
                var userName = User.Identity.Name;
                var user     = UserManager.FindByName(userName);
                publishingReview.UserId = user.Id;
                var result = await PublishingReviewService.PostReview(publishingReview);

                Session.Remove("PublishingReview");
                return(PartialView("_AddReviewPostPartial", result));
            }

            //Jeśli użytkownik nie jest zalogowany to zwraca błąd z informacją o zalogowaniu i wrzuca dane do ciasteczka
            var loginErrorModel = new ReviewViewModel
            {
                LoginErrorMessage = "Musisz być zalogowany, aby dodać swoją opinię",
                ReturnUrl         = returnUrl
            };

            Session["PublishingReview"] = publishingReview;

            return(PartialView("_AddReviewPostPartial", loginErrorModel));
        }
Example #2
0
        public async Task <ActionResult> GetMyPublishingReviewsPartial()
        {
            var userId = User.Identity.GetUserId();
            var myPublishingReviews = await PublishingReviewService.GetMyReviews(userId);

            return(PartialView(myPublishingReviews));
        }
Example #3
0
        public async Task <ActionResult> MyReviews()
        {
            var userId          = User.Identity.GetUserId();
            var myAuthorReviews = await AuthorReviewService.GetMyReviews(userId);

            var myBookReviews = await BookReviewService.GetMyReviews(userId);

            var myPublishingReviews = await PublishingReviewService.GetMyReviews(userId);

            var vm = new MyReviewsViewModel
            {
                MyAuthorReviews     = myAuthorReviews,
                MyBookReviews       = myBookReviews,
                MyPublishingReviews = myPublishingReviews
            };

            return(View(vm));
        }
Example #4
0
        public async Task <PartialViewResult> EditReviewPost([Bind(Include = "Id,PublishingId,UserId,ReviewRate,Description")] PublishingReview publishingReview)
        {
            var model = new InfoViewModel();

            //tylko twórca recenzji może ją zmienić
            if (!User.Identity.IsAuthenticated || !User.Identity.GetUserId().Equals(publishingReview.UserId))
            {
                model.Errors.Add("Nie jesteś twórca tej recenzji. Nie możesz jej zmienić");
            }
            else
            {
                await PublishingReviewService.Update(publishingReview);

                model.Message = "Twoja recenzja została zmieniona";
            }


            return(PartialView("_infoPartial", model));
        }
Example #5
0
        public async Task <PartialViewResult> DeleteReview(int publishingReviewId)
        {
            var model = new InfoViewModel();

            //tylko twórca recenzji może ją usunąć
            var publishingReview = await PublishingReviewService.GetById(publishingReviewId);

            if (!User.Identity.IsAuthenticated || !User.Identity.GetUserId().Equals(publishingReview.UserId))
            {
                model.Errors.Add("Nie jesteś twórca tej recenzji. Nie możesz jej usunąć");
            }
            else
            {
                await PublishingReviewService.Delete(publishingReviewId);

                model.Message = "Twoja recenzja została usunięta";
            }


            return(PartialView("_infoPartial", model));
        }
Example #6
0
        public async Task <PartialViewResult> EditReview(int publishingReviewId)
        {
            var model = await PublishingReviewService.GetById(publishingReviewId);

            return(PartialView(model));
        }
Example #7
0
 public PartialViewResult GetAllByPublishingId(int publishingId)
 => PartialView(PublishingReviewService.GetAllByPublishingIdSync(publishingId));
Example #8
0
        public PartialViewResult ShowVote(int publishingId)
        {
            var model = PublishingReviewService.CalculateVote(publishingId);

            return(PartialView("_ShowVotePartial", model));
        }