public void CheckBOLayer() { //Arrange SkuIdsDto request = new SkuIdsDto { ItemA = 1, ItemB = 2, ItemC = 3, ItemD = 4 }; //Act var moc = new Mock <IProdcutService>(); moc.Setup(m => m.CalculatePromotionA(It.IsAny <SkuIdsDto>())).Returns(100); moc.Setup(m => m.CalculatePromotionB(It.IsAny <SkuIdsDto>())).Returns(100); moc.Setup(m => m.CalculatePromotionCD(It.IsAny <SkuIdsDto>())).Returns(100); moc.Setup(m => m.GetTotalPrice(It.IsAny <SkuIdsDto>())).Returns(100); var proBo = new PromotionBO(moc.Object); Response Resp = proBo.GetCheckoutTotal(request); //Assert Assert.Equal(100, Resp.TotalAmount); }
public JsonResult DeletePromotion(int StoreID, long ID) { if (_session.IsLogin && _session.IsStore && !_session.IsAdmin) { if (_session.StoreID == StoreID) { IPromotion _cls = new PromotionBO(); var IsResult = _cls.Delete(ID); return Json(new { IsOk = IsResult }, JsonRequestBehavior.AllowGet); } else return Json(new { IsOk = false }, JsonRequestBehavior.AllowGet); } else RedirectToAction("index", "backend"); return Json("[]", JsonRequestBehavior.AllowGet); }
public JsonResult SavePromotion(Promotion master, List<PromotionDetail> detail) { if (_session.IsLogin && _session.IsStore && !_session.IsAdmin) { IPromotion _cls = new PromotionBO(); var IsResult = _cls.SavePromotion(master, detail); return Json(new { IsOk = IsResult }, JsonRequestBehavior.AllowGet); } else RedirectToAction("index", "backend"); return Json("[]", JsonRequestBehavior.AllowGet); }
public JsonResult GetPromotionItem(long id) { if (_session.IsLogin && _session.IsStore && !_session.IsAdmin) { if (id == -1) { string jsonData = ""; jsonData = "{\"master\":" + new JavaScriptSerializer().Serialize(new Promotion()); jsonData += ",\"detail\":[]}"; return Json(jsonData, JsonRequestBehavior.AllowGet); } else { string jsonData = ""; IPromotion _cls = new PromotionBO(); var data = _cls.GetPromotionItem(id); jsonData = "{\"master\":" + new JavaScriptSerializer().Serialize(data[0]); jsonData += ",\"detail\":" + new JavaScriptSerializer().Serialize(data[1]) + "}"; ; return Json(jsonData, JsonRequestBehavior.AllowGet); } } else RedirectToAction("index", "backend"); return Json("[]", JsonRequestBehavior.AllowGet); }
public JsonResult GetPromotion(DateTime FromDate, DateTime ToDate, bool IsItem) { if (_session.IsLogin && _session.IsStore && !_session.IsAdmin) { string jsonData = "[]"; IPromotion _cls = new PromotionBO(); var data = _cls.GetPromotion(_session.SiteID, _session.StoreID, FromDate, ToDate, IsItem); if (data != null) jsonData = new JavaScriptSerializer().Serialize(data); return Json(jsonData, JsonRequestBehavior.AllowGet); } else RedirectToAction("index", "backend"); return Json("[]", JsonRequestBehavior.AllowGet); }
public JsonResult GetItemForPromotion(int StoreID, string TextSearch) { if (_session.IsLogin && _session.IsStore && !_session.IsAdmin) { string jsonData = "[]"; IPromotion _cls = new PromotionBO(); var data = _cls.GetItemForPromotion(StoreID, TextSearch); if (data != null) jsonData = new JavaScriptSerializer().Serialize(data); return Json(jsonData, JsonRequestBehavior.AllowGet); } else RedirectToAction("index", "backend"); return Json("[]", JsonRequestBehavior.AllowGet); }
public PromotionEngineControllerXunit() { prodcutService = new ProdcutService(); promotionBO = new PromotionBO(prodcutService); promotionEngineController = new PromotionEngineController(promotionBO); }