public ActionResult Delete(int AlbumID) { if (User.Identity.IsAuthenticated) { var identity = User.Identity.Name; int?userID = Userrepo.GetID(identity); var albumToRemove = repo.ByID(AlbumID); if (albumToRemove.UserID == userID) { if (albumToRemove.photos != null) { foreach (var photo in albumToRemove.photos) { var filePath = Request.MapPath(photo.Path); FileInfo file = new FileInfo(filePath); if (file.Exists) { file.Delete(); } } } repo.Delete(albumToRemove.ID); return(Content("Album borttaget")); } } return(Content("Gick inte att ta bort albumet"));; }
/// <summary> /// Delete the object to which this behavior belongs from the data store and optionally the file system. /// </summary> /// <param name="deleteFromFileSystem">Indicates whether to delete the file or directory from the hard drive in addition /// to deleting it from the data store. When true, the object is deleted from both the data store and hard drive. When /// false, only the record in the data store is deleted.</param> public void Delete(bool deleteFromFileSystem) { if (deleteFromFileSystem) { DeleteFromFileSystem(this._albumObject); } else { DeleteSupportFilesOnly(this._albumObject); } if (this._albumObject.IsRootAlbum) { // Don't delete the root album; just its contents. DeleteAlbumContents(deleteFromFileSystem); } else { using (var repo = new AlbumRepository()) { repo.Delete(this._albumObject); repo.Save(); } } }
public ActionResult DeleteConfirmed(int id) { Album album = AlbumDB.Find(id); AlbumDB.Delete(album); return(RedirectToAction("Index")); }
public void DeleteAlbum(int albumId) { using (var uow = UnitOfWorkProvider.Create()) { _albumRepository.Delete(albumId); uow.Commit(); } }
public void Delete_Album_NoPhotos() { //set up AlbumDetailModel album = new AlbumDetailModel() { DateTime = DateTime.Now, Description = "Description", Id = TestGuidList.ElementAt(0), Name = "TmpAlbum", Photos = null }; albumRepo.Insert(album); //unit test albumRepo.Delete(TestGuidList.ElementAt(0)); //Assert Assert.Null(albumRepo.GetById(TestGuidList.ElementAt(0))); }
public void Delete_Decreses_Count_Of_Albums() { var currentCount = db.Albums.Count(); var someAlbum = underTest.GetById(3); underTest.Delete(someAlbum); var endCount = db.Albums.Count(); Assert.Equal(currentCount - 1, endCount); }
public void DeleteAlbum(int albumId) { if (albumId < 1) { throw new ArgumentOutOfRangeException("Album service - DeleteAlbum(...) albumId cannot be lesser than 1"); } using (var uow = UnitOfWorkProvider.Create()) { albumRepository.Delete(albumId); uow.Commit(); } }
public void TestAlbumRepo_DeleteAlbum() { Album _alb = new Album("Tintin au Tibet", "Les Aventures de Tintin", "Tintin au Tibet.jpg", "BD", "Aventure", "Casterman", "Hergé"); _albumRepository.Delete(_alb); bool possede = false; var albums = _albumRepository.GetAll(); if (albums.Contains(_alb)) { possede = true; } Assert.IsFalse(possede); }
private void DeleteAlbum() { if (Detail.Id != Guid.Empty) { var result = MessageBox.Show("Naozaj chcete vymazať tento album ? ", "Vymazanie albumu", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.No) { return; } var detailId = Detail.Id; Detail = new AlbumDetailModel(); albumRepository.Delete(detailId); messenger.Send(new DeleteAlbumMessage(detailId)); } }
public JsonResult Delete(int id) { try { Album album = repoAlbum.GetAlbum(id); repoAlbum.Delete(album); repoAlbum.Save(); //200 OK...could be 204 No Content if no status describing entity in response. //Response.StatusCode = 204; return(this.Json(new { success = true })); } catch { return(this.Json(new { success = false })); } }
public IActionResult DeleteAlbums([FromRoute] int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var albums = albumRepo.Get(id); if (albums == null) { return(NotFound()); } albumRepo.Delete(id); return(Ok(albums)); }
public IActionResult DeleteAlbum([FromRoute] long id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var album = _repo.SearchFor(m => m.Id == id); if (album == null) { return(NotFound()); } _repo.Delete(album.First()); return(Ok(album)); }
public ActionResult Delete(long id) { var album = AlbumRepository.Get(id); var zipPath = Path.Combine(Server.MapPath("~/Content/Song"), album.Name + ".zip"); if (System.IO.File.Exists(zipPath)) { System.IO.File.Delete(zipPath); } var albumPath = Path.Combine(Server.MapPath("~/Content/Song"), album.Name); if (System.IO.File.Exists(albumPath)) { System.IO.File.Delete(albumPath); } AlbumRepository.Delete(id); AlbumRepository.Reorder(); return(RedirectToAction("Albums")); }
public void Commands() { var albumRepo = new AlbumRepository(); var albumTest = new Albums() { Name = "Album test", ArtistId = 1, AlbumTypeId = 1, LabelId = 1, Stock = 1 }; albumRepo.Insert(albumTest); albumRepo.Save(); albumTest.Stock = 5; albumRepo.Update(albumTest); albumRepo.Save(); Assert.AreEqual(5, albumRepo.First(a => a.Id == albumTest.Id).Stock); albumRepo.Delete(albumTest); albumRepo.Save(); Assert.IsNull(albumRepo.First(a => a.Id == albumTest.Id)); }
public async Task DeletePhoto() { // Arrange var options = new DbContextOptionsBuilder <MyAlbumDbContext>() .UseInMemoryDatabase(databaseName: "AlbumRepository_DeleteAlbum_MyAlbumDatabase") .Options; using (var context = new MyAlbumDbContext(options)) { IEnumerable <Album> seedAlbums = SeedAlbums(context); UnitOfWork unitOfWork = new UnitOfWork(context); AlbumRepository albumRepository = new AlbumRepository(context); int count = seedAlbums.Count(); foreach (var album in seedAlbums) { // Act albumRepository.Delete(album); await unitOfWork.CompleteAsync(); // Assert Assert.Equal(--count, context.Albums.Count()); } } }
// GET: Album/Delete/5 public ActionResult Delete(Guid id) { AlbumRepository.Delete(id); return(null); }
public void Delete(int id) { _albumRepository.Delete(id); }
public void Delete(Album album) { repository.Delete(album); }
public ActionResult Delete(int id) { //TODO access control AlbumRepository albums = new AlbumRepository(); AlbumModel album = albums.GetById(id); albums.Delete(album); return RedirectToAction("Manage"); }