public async Task DeleteTest() { var fakeRepository = Mock.Of <IPhotoRepository>(); var PhotoService = new PhotoService(fakeRepository); int PhotoId = 1; await PhotoService.Delete(PhotoId); }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { // ChkAdminLevel("manager_list", MXEnums.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { try { _service.Delete(id); sucCount += 1; } catch (Exception) { errorCount += 1; } } } AddAdminLog(MXEnums.ActionEnum.Delete.ToString(), "删除湖怪活动信息" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("photolist.aspx", "keywords={0}", this.keywords), "Success"); }
private void DeletePic(string pictureIdStr) { var pictureId = new Guid(pictureIdStr); var myShowArt = GetPicture(pictureId); var myShowArtId = myShowArt.MyShowArtId.ToString(); var photoId = myShowArt.Art.Photo.PhotoId.ToString(); var filename = myShowArt.Art.Photo.FileName.ToString(); var artService = new ArtService(Ioc.GetInstance <IArtRepository>()); var photoService = new PhotoService(Ioc.GetInstance <IPhotoRepository>()); var myShowArtService = new MyShowArtService(Ioc.GetInstance <IMyShowArtRepository>()); using (IUnitOfWork uow = UnitOfWork.Begin()) { photoService.Delete(myShowArt.Art.Photo); artService.Delete(myShowArt.Art); myShowArtService.Delete(myShowArt); uow.Commit(); } log.WriteLine("Deleted myShowArt Id: " + myShowArtId); log.WriteLine("Deleted photo Id: " + photoId + "and filename: " + filename); log.WriteLine("Deleted picture Id: " + pictureId); Response.Redirect(LinkBuilder.MyPicturesLink(new Guid(hdnShowId.Value))); }
private void DeletePoster(string posterIdStr) { var posterId = new Guid(posterIdStr); var myShowPoster = GetPoster(posterId); var myShowPosterId = myShowPoster.MyShowPosterId.ToString(); var photoId = myShowPoster.Poster.Photo.PhotoId.ToString(); var filename = myShowPoster.Poster.Photo.FileName.ToString(); var posterService = new PosterService(Ioc.GetInstance <IPosterRepository>()); var photoService = new PhotoService(Ioc.GetInstance <IPhotoRepository>()); var myShowPosterService = new MyShowPosterService(Ioc.GetInstance <IMyShowPosterRepository>()); using (IUnitOfWork uow = UnitOfWork.Begin()) { var photo = myShowPoster.Poster.Photo; var poster = myShowPoster.Poster; photoService.Delete(photo); posterService.Delete(poster); myShowPosterService.Delete(myShowPoster); uow.Commit(); } log.WriteLine("Deleted myShowPoster Id: " + myShowPosterId); log.WriteLine("Deleted photo Id: " + photoId + "and filename: " + filename); log.WriteLine("Deleted picture Id: " + posterId); Response.Redirect(LinkBuilder.MyPostersLink(new Guid(hdnShowId.Value))); }
public ActionResult Delete(int id) { Photo photo = _photoService.Get(id); var galleryId = photo.Gallery.Id; _photoService.Delete(id); return(RedirectToAction("Details", "Galleries", new { Id = galleryId })); }
public IActionResult Delete(int[] photos) { { if (photos != null) { foreach (var item in photos) { photoService.Delete(item); } return(Ok()); } } return(BadRequest()); }
static void Main() { var locationService = new LocationService(); var locations = locationService.GetAll(); var location = locationService.GetById(locations[0].Id); var hotelService = new HotelService(); var hotel = hotelService.GetById(location.Hotels[0].Id); var roomService = new RoomService(); var room = roomService.GetById(hotel.Rooms[0].Id); var photoService = new PhotoService(); // Delete any existing photos foreach (var p in room.Photos) { photoService.Delete(p.Id); } Console.WriteLine("Adding photo to: {0}", room.Name); var photo = new Photo { Title = "A view of the room", Description = "A beautiful room with wonderful views of the neighbours walls", RoomId = room.Id }; const string roomPhoto = @"Pictures\roomview.jpg"; const string roomPhoto2 = @"Pictures\roomview_2.jpg"; photo.Data = ReadPhotoData(roomPhoto); photoService.Insert(photo); photo.Data = ReadPhotoData(roomPhoto2); photoService.Update(photo); }
public IActionResult DeletePhoto(int photoId) { photoService.Delete(photoId); return(Ok()); }
public async Task Delete(Guid id) { await photoService.Delete(id); }
public bool Delete(int id) { return(photoService.Delete(id)); }