public async Task DeleteBaner_ValidArgument_InvokeRepository() { await _bannerService.DeleteBanner(new Banner()); _repositoryMock.Verify(c => c.DeleteAsync(It.IsAny <Banner>()), Times.Once); _mediatorMock.Verify(c => c.Publish(It.IsAny <EntityDeleted <Banner> >(), default(CancellationToken)), Times.Once); }
public JsonResult DeleteBanner(BannerModel obj) { var baseUrl = Server.MapPath("~/Images/Banners/") + obj.FileName; System.IO.File.Delete(baseUrl); BannerService.DeleteBanner(obj.Id); return(Json(true, JsonRequestBehavior.AllowGet)); }
// DELETE: api/banner/id public async Task <IHttpActionResult> Delete(string id) { if (await _bannerService.DeleteBanner(id) > 0) { return(Ok()); } return(NotFound()); }
public JsonResult DelBanner(int id) { if (id < 0) { return(Json(new ResponseModel { code = 0, result = "参数有误" })); } return(Json(_bannerService.DeleteBanner(id))); }
public JsonResult DleteBanner(int ID) { if (ID <= 0) { return(Json(new ResponseModel { code = 0, result = "ID不正确" })); } return(Json(_bannerService.DeleteBanner(ID))); }
public JsonResult DeleteBanner(int id) { if (id <= 0) { return(Json(new ResponseModel { code = 0, result = "参数有误!" })); } return(Json(_bs.DeleteBanner(id))); }
public JsonResult DelBanner(int id) { //TODO:需要添加删除数据库记录的同时删除文件夹里的图片文件功能 if (id <= 0) { return(Json(new ResponseModel { code = 0, result = "parameter error" })); } return(Json(_bannerService.DeleteBanner(id))); }
public void DeleteBannerTest() { BannerContext context = new BannerContext(new DbContextOptionsBuilder <BannerContext>().UseInMemoryDatabase(databaseName: "BannerItemsTest4").Options); var testBanners = TestBanners(); context.Banners.AddRange(testBanners); context.SaveChanges(); var bannerService = new BannerService(context); bannerService.DeleteBanner(2); var actual = bannerService.GetAllBanners(); testBanners.Remove(testBanners.Find(x => x.Id == 2)); var expected = testBanners; Assert.Equal(expected, actual); }
public void DeleteBanner_NullArgument_ThrowException() { Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await _bannerService.DeleteBanner(null), "banner"); }