public ActionResult Details(long goodId) { try { var store = new StoreAction(); var good = store.GetGoodInfo(goodId); var model = new GoodDetailsViewModel(good); model.feedbacks = store.GetFeedBack(goodId); model.canSendFeedback = Session.IsAuth() && !model.feedbacks.Any(s => s.userId == Session.GetUserId()); if (Session.IsAuth()) { var customer = new CustomerAction(Session.GetUserId()); customer.SetThatWatching(goodId); } SetPratentGroupLinks(good.groupId); (ViewBag.Links as Queue <Link>).Enqueue(new Link { description = good.name, url = $"~/Details/{good.groupId}/{good.id}" }); return(View(model)); } catch (Exception ex) { HttpContext.Response.Redirect("/Error/_404", true); return(null); } }
public void TestGetFeedBack_CountNotNull() { var storeAction = new StoreAction(); var result = storeAction.GetFeedBack(2); // TODO: Add your test code here Assert.IsTrue(result?.Count() > 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); }
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)); }