public void Delete(int id) { FolderDAO dao = new FolderDAO(); var folder = dao.GetById(id); folder.IsActive = false; folder.Update(); FileDAO fileDAO = new FileDAO(); var allfiles = fileDAO.GetAll(); var files = (from file in allfiles where file.ParenFolderId == id select file).ToList <Entities.File>(); foreach (var file in files) { file.IsActive = false; file.Update(); } }
public void Insert__WithCorrectData__ReturnsReturnsIdOfInsertedRecord() { Folder folder = new Folder(); folder.Name = "Text Folder"; folder.ParentFolderId = -1; folder.IsActive = true; folder.CreatedBy = 1; folder.CreatedOn = DateTime.Now.Truncate(TimeSpan.FromSeconds(1)); folder.Id = dao.Insert(folder); var dbFolder = dao.GetById(folder.Id); Assert.AreEqual(dbFolder.Id, folder.Id); Assert.AreEqual(dbFolder.Name, folder.Name); Assert.AreEqual(dbFolder.ParentFolderId, folder.ParentFolderId); Assert.AreEqual(dbFolder.IsActive, folder.IsActive); Assert.AreEqual(dbFolder.CreatedBy, folder.CreatedBy); Assert.AreEqual(dbFolder.CreatedOn, folder.CreatedOn); }