Example #1
0
        public void TestLeaveFeadback_IsNotNull()
        {
            var customer = new CustomerAction(8);
            var store    = new StoreAction();

            var feedback = new FeedBack
            {
                goodId  = store.GetAllGoods().First().id,
                mark    = 3,
                message = Guid.NewGuid().ToString()
            };

            customer.LeaveFeadback(feedback);
            var feeds       = store.GetFeedBack(feedback.goodId);
            var newFeedBack = feeds.FirstOrDefault(s => s.mark == feedback.mark && s.message == feedback.message && s.userId == feedback.userId);

            // TODO: Add your test code here
            Assert.IsNotNull(newFeedBack);
        }
Example #2
0
        public ActionResult SendFeedback(SendFeedbackViewModel model)
        {
            var url             = Request.UrlReferrer.AbsoluteUri;
            var store           = new StoreAction();
            var canSendFeedback = Session.IsAuth() && !store.GetFeedBack(model.goodId).Any(s => s.userId == Session.GetUserId());

            if (canSendFeedback)
            {
                var customer = new CustomerAction(Session.GetUserId());
                customer.LeaveFeadback(new FeedBack
                {
                    date    = DateTime.Now,
                    goodId  = model.goodId,
                    mark    = model.score,
                    message = model.message
                });
            }
            return(RedirectPermanent(url));
        }