public ActionResult AjaxSaveReplay() { string sysNoText = Request.Form["SysNo"]; int sysNo = 0; int.TryParse(sysNoText, out sysNo); if (sysNo > 0) { string content = Request.Form["Content"]; if (!string.IsNullOrEmpty(content)) { ProductReviewReplyInfo entity = new ProductReviewReplyInfo(); entity.Content = content; entity.ReviewSysNo = sysNo; entity.SellerSysNo = UserAuthHelper.GetCurrentUser().SellerSysNo; entity.Status = "A"; entity.StatusValue = "A"; entity.Type = "M"; entity.NeedAdditionalText = "N"; entity.InUserName = UserAuthHelper.GetCurrentUser().UserID; entity.InUser = UserAuthHelper.GetCurrentUser().UserID; entity.InDate = DateTime.Now; ProductReviewService.AddProductReviewReply(entity); return(Json(entity)); } } return(Json(1)); }
public void UpdateReviewTest() { AdventureWorksDataContext db = new AdventureWorksDataContext(); ProductService pr = new ProductService(); ProductReviewService prs = new ProductReviewService(); Product product = new Product(); product.Name = "Test-Update-ProductReview2"; product.ProductNumber = "Test-U-PR"; pr.CreateProduct(product); ProductReview productReview = new ProductReview(); productReview.Rating = 1; productReview.Comments = "Comments-Test"; productReview.ProductID = product.ProductID; prs.CreateReview(productReview); productReview.Comments = "UPDATED-Comments-Test"; prs.UpdateReview(productReview); ProductReview actualProductReview = (from p in db.ProductReview where p.ProductID.Equals(product.ProductID) select p).First(); Assert.AreEqual("UPDATED-Comments-Test", actualProductReview.Comments); prs.DeleteReview(productReview); pr.DeleteProduct(product); }
public ActionResult AjaxMaintainQuery() { string sysNoText = Request.Form["SysNo[]"]; if (!string.IsNullOrEmpty(sysNoText)) { int sysNo = 0; int.TryParse(sysNoText, out sysNo); if (sysNo > 0) { int?currentSellerSysNo = null; int currentSellerSysNoValue = UserAuthHelper.GetCurrentUser().SellerSysNo; if (currentSellerSysNoValue > 0) { currentSellerSysNo = currentSellerSysNoValue; } var result = ProductReviewService.GetProductReviewFactoryReply(sysNo, currentSellerSysNo); return(AjaxGridJson(result)); } } return(Json(1)); }
// GET: ProductInfo public ActionResult ProductInfo() { //查询出商品信息 var code = Request["id"]; ViewBag.code = Request["id"]; var pro = ProService.GetEntity(x => x.Code == code); ViewBag.name = pro.Name; ViewBag.describe = pro.Describe;//描述 ViewBag.price = pro.Price; ViewBag.img = pro.img; //遍历出来图片 //for(int i=0;i < pro.img.Split(',').Length;i++) //{ // ViewBag.img[i] = pro.img.Split(',')[i]; //} ViewBag.img1 = pro.img.Split(',')[0]; ViewBag.img2 = pro.img.Split(',')[1]; // ViewBag.img3 = pro.img.Split(',')[2]; //根据商品查询出来库存 Stock stock = StockService.GetEntity(x => x.BillId == code); ViewBag.stock = stock.num; PropertyInfo[] pis = typeof(Stock).GetProperties();//反射 暂时用不到,用来遍历实体用 //根据商品查询处商品规格 int? id = pro.SpecificationId; Specification specification = SpecificationService.GetEntity(x => x.Id == id); var specification1 = SpecificationService.GetEntities(x => x.ProCode == pro.Code); ViewBag.Spcification = specification1; //产品描述 ViewBag.describe = pro.Describe; //用户评价 var proDuctReview = ProductReviewService.GetEntities(x => x.Pcode == pro.Code); ViewBag.ProReview = proDuctReview.ToList(); return View(); }
public async void Get_null_record() { var mock = new ServiceMockFacade <IProductReviewRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ProductReview>(null)); var service = new ProductReviewService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ProductReviewModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLProductReviewMapperMock, mock.DALMapperMockFactory.DALProductReviewMapperMock); ApiProductReviewResponseModel response = await service.Get(default(int)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public async void ByProductIDReviewerName_Not_Exists() { var mock = new ServiceMockFacade <IProductReviewRepository>(); mock.RepositoryMock.Setup(x => x.ByProductIDReviewerName(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult <List <ProductReview> >(new List <ProductReview>())); var service = new ProductReviewService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ProductReviewModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLProductReviewMapperMock, mock.DALMapperMockFactory.DALProductReviewMapperMock); List <ApiProductReviewResponseModel> response = await service.ByProductIDReviewerName(default(int), default(string)); response.Should().BeEmpty(); mock.RepositoryMock.Verify(x => x.ByProductIDReviewerName(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())); }
public async void Create() { var mock = new ServiceMockFacade <IProductReviewRepository>(); var model = new ApiProductReviewRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <ProductReview>())).Returns(Task.FromResult(new ProductReview())); var service = new ProductReviewService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ProductReviewModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLProductReviewMapperMock, mock.DALMapperMockFactory.DALProductReviewMapperMock); CreateResponse <ApiProductReviewResponseModel> response = await service.Create(model); response.Should().NotBeNull(); mock.ModelValidatorMockFactory.ProductReviewModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiProductReviewRequestModel>())); mock.RepositoryMock.Verify(x => x.Create(It.IsAny <ProductReview>())); }
public async void All() { var mock = new ServiceMockFacade <IProductReviewRepository>(); var records = new List <ProductReview>(); records.Add(new ProductReview()); mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records)); var service = new ProductReviewService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ProductReviewModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLProductReviewMapperMock, mock.DALMapperMockFactory.DALProductReviewMapperMock); List <ApiProductReviewResponseModel> response = await service.All(); response.Should().HaveCount(1); mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>())); }
public async void Delete() { var mock = new ServiceMockFacade <IProductReviewRepository>(); var model = new ApiProductReviewRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask); var service = new ProductReviewService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ProductReviewModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLProductReviewMapperMock, mock.DALMapperMockFactory.DALProductReviewMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>())); mock.ModelValidatorMockFactory.ProductReviewModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); }
public ActionResult AjaxQuery() { ProductReviewQueryFilter queryCriteria = BuildQueryFilterEntity <ProductReviewQueryFilter>(); queryCriteria.SortFields = "ProductSysNo"; int?currentSellerSysNo = null; int currentSellerSysNoValue = UserAuthHelper.GetCurrentUser().SellerSysNo; if (currentSellerSysNoValue > 0) { currentSellerSysNo = currentSellerSysNoValue; } queryCriteria.SellerSysNo = currentSellerSysNo; QueryResult <ProductReviewQueryBasicInfo> result = ProductReviewService.QueryProductReviewBasicInfoList(queryCriteria); return(AjaxGridJson(result)); }
public ActionResult AjaxChangeStatus() { List <int> sysNoList = new List <int>(); string sysNoText = Request.Form["SysNo"]; string statusText = Request.Form["Status"]; string[] array = sysNoText.Split(','); foreach (var item in array) { int sysNo = 0; if (int.TryParse(item, out sysNo)) { sysNoList.Add(sysNo); } } string currentUser = UserAuthHelper.GetCurrentUser().UserID; if (sysNoList.Count > 0) { if (statusText == "A") { ProductReviewService.BatchSetProductReviewValid(sysNoList, currentUser); } else if (statusText == "D") { ProductReviewService.BatchSetProductReviewInvalid(sysNoList, currentUser); } else if (statusText == "E") { ProductReviewService.BatchSetProductReviewRead(sysNoList, currentUser); } } return(Json(1)); }
public void GetAllReviewsByProductIdTest() { AdventureWorksDataContext db = new AdventureWorksDataContext(); ProductService pr = new ProductService(); ProductReviewService prs = new ProductReviewService(); Product product = new Product(); product.Name = "Test-GetAll-ProductReview1"; product.ProductNumber = "Test-GetAll-PR"; pr.CreateProduct(product); ProductReview productReview1 = new ProductReview(); productReview1.Rating = 1; productReview1.Comments = "Comments-Test1"; productReview1.ProductID = product.ProductID; prs.CreateReview(productReview1); ProductReview productReview2 = new ProductReview(); productReview2.Rating = 2; productReview2.Comments = "Comments-Test2"; productReview2.ProductID = product.ProductID; prs.CreateReview(productReview2); List <ProductReview> productReviews = (from p in db.ProductReview where p.ProductID.Equals(product.ProductID) select p).ToList(); Assert.AreEqual(2, productReviews.Count); prs.DeleteReview(productReview1); prs.DeleteReview(productReview2); pr.DeleteProduct(product); }
public void CreateDeleteReviewTest() { AdventureWorksDataContext db = new AdventureWorksDataContext(); ProductService pr = new ProductService(); ProductReviewService prs = new ProductReviewService(); Product product = new Product(); product.Name = "Test-Create-ProductReview"; product.ProductNumber = "Test-Number-CD-PR"; pr.CreateProduct(product); ProductReview productReview = new ProductReview(); productReview.Rating = 1; productReview.Comments = "Comments-Test"; productReview.ProductID = product.ProductID; prs.CreateReview(productReview); ProductReview actualProductReview = (from p in db.ProductReview where p.Comments.Equals(productReview.Comments) select p).First(); Assert.AreEqual(1, actualProductReview.Rating); prs.DeleteReview(productReview); List <ProductReview> actualProductsReviewsAfterDelete = (from p in db.ProductReview where p.Comments.Equals(productReview.Comments) select p).ToList(); Assert.AreEqual(0, actualProductsReviewsAfterDelete.Count); pr.DeleteProduct(product); }
public ActionResult Maintain() { string sysNoText = Request["SysNo"]; if (!string.IsNullOrEmpty(sysNoText)) { int sysNo = 0; int.TryParse(sysNoText, out sysNo); ProductReviewInfo entity = ProductReviewService.LoadProductReviewWithoutReply(sysNo); if (entity == null) { return(RedirectToAction("Index", "ProductReview")); } ViewBag.ProductReviewInfo = entity; } else { return(RedirectToAction("Index", "ProductReview")); } return(View()); }