Пример #1
0
        public IActionResult RedirectToReview(Review review)
        {
            var Customer = SessionHelper.GetObjectFromJson <Customer>(HttpContext.Session, "User");

            var ResturantId = HttpContext.Session.GetInt32("ResturantId");

            var CustomerId    = Customer.ID;
            var reviewValue   = review.reviewValue;
            var resturantName = rewardsManager.GetSelectedResturantName(ResturantId);

            var result = rewardsManager.GetCustomerRewardModel(CustomerId, ResturantId);

            if (string.IsNullOrWhiteSpace(review.FromTableReady) && string.IsNullOrWhiteSpace(review.FromFacebook) && string.IsNullOrWhiteSpace(review.FromGoogle) && reviewValue == "-1")
            {
                return(RedirectToAction("RewardPage", "Dashboard"));
            }
            else if (result == null)
            {
                var discount = 0;
                var Checked  = false;
                if (reviewValue == "1")
                {
                    discount += 10;
                    Checked   = true;
                }
                else if (reviewValue == "0")
                {
                    Checked = false;
                }

                if (!string.IsNullOrWhiteSpace(review.FromTableReady))
                {
                    discount += 5;
                }

                if (!string.IsNullOrWhiteSpace(review.FromFacebook))
                {
                    discount += 5;
                }

                if (!string.IsNullOrWhiteSpace(review.FromGoogle))
                {
                    discount += 5;
                }

                Reward rewardModel = new Reward
                {
                    Points       = discount,
                    CustomerID   = CustomerId,
                    RestaurantID = ResturantId,
                    IsChecked    = Checked
                };

                var AddedresultValue = rewardsManager.UpdateCustomerRewardModel(rewardModel);
                if (AddedresultValue != 0)
                {
                    return(RedirectToAction("RewardPage", "Dashboard"));
                }
                else
                {
                    ViewBag.Msg = "Review Not Added";
                }
            }
            else
            {
                if (reviewValue == "1")
                {
                    result.Points   += 10;
                    result.IsChecked = true;
                }
                else if (reviewValue == "0")
                {
                    result.IsChecked = false;
                }

                if (!string.IsNullOrWhiteSpace(review.FromTableReady))
                {
                    result.Points += 5;
                }

                if (!string.IsNullOrWhiteSpace(review.FromFacebook))
                {
                    result.Points += 5;
                }

                if (!string.IsNullOrWhiteSpace(review.FromGoogle))
                {
                    result.Points += 5;
                }

                var updateResult = rewardsManager.UpdateCustomerRewardModel(result);
                if (updateResult != 0)
                {
                    return(RedirectToAction("RewardPage", "Dashboard"));
                }
                else
                {
                    ViewBag.Msg = "Review Not Added";
                }
            }

            return(View());
        }