Exemplo n.º 1
0
        public IActionResult RateUserAjax(RateModel model)
        {
            if (!_workContext.CurrentCustomer.IsRegistered())
            {
                return(Redirect("/Login"));
            }

            if (!ModelState.IsValid)
            {
                ViewBag.Added = false;
                return(View("~/Themes/Pavilion/Views/Harag/Rate/RateUser.cshtml", model));
            }

            var user = _customerContext.GetCustomerById(model.UserId);

            if (user == null)
            {
                return(NotFound());
            }

            var rate = new Z_Harag_Rate {
                AdviceDeal  = model.AdviceDeal,
                IsBuyDone   = model.IsBuyDone,
                RateComment = model.RateComment,
                CustomerId  = _workContext.CurrentCustomer.Id,
                UserId      = user.Id,
                BuyTime     = model.WhenBuyDone
            };

            var posts        = _rateRepository.AddUserRate(rate);
            var notification = _notificationService.PushRateNotification(_workContext.CurrentCustomer.Id, user.Id, model.AdviceDeal);

            ViewBag.Added = true;

            return(View("~/Themes/Pavilion/Views/Harag/Rate/RateUser.cshtml", model));
        }
Exemplo n.º 2
0
 public bool AddUserRate(Z_Harag_Rate rate)
 {
     _rateService.Insert(rate);
     return true;
 }