public void IsPrefixStringUnique_NotExistedString_Success() { _repository.Delete("1"); var result = _repository.IsPrefixStringUnique("123.123.123.0/30"); Assert.That(result, Is.EqualTo("")); }
/// <summary> /// Supprime le fichier. /// </summary> /// <param name="id">Identifiant du fichier.</param> public void DeleteFile(string id) { FileModel fileModel = GetFile(id); File.Delete(fileModel.Url); _fileRepository.Delete(id); }
public bool RemoveFile(string serverPath, FileRepository fRepository, int fileId) { File file = fRepository.Get(fileId); if (file != null) { try { if (System.IO.File.Exists(System.IO.Path.Combine(serverPath + file.Path, file.Name))) { System.IO.File.Delete(System.IO.Path.Combine(serverPath + file.Path, file.Name)); fRepository.Delete(fileId); return(true); } else { return(false); } } catch (System.IO.IOException ioExp) { } } return(false); }
public void DeleteNotExistedFileID() { FileRepository repository = new FileRepository(); int fileID = FileRepository.array.Max(p => p.ID) + 1; Assert.IsFalse(repository.Delete(fileID)); }
public async Task Remove(Guid fileId) { var file = await _fileRepository.Get(fileId); await file.Delete(_objectStorage); await _fileRepository.Delete(fileId); }
public void Delete() { // Act testSubject.Delete("1"); // Assert Assert.False(testSubject.Exists("1")); }
public async Task Delete_ValidParameters_SetsCorrectResourceAndMethod() { var sut = new FileRepository(_requestFactory); await sut.Delete(0, "filePath", "branchName", "commitMessage"); _requestFactory.Received().Create("projects/{projectId}/repository/files", Method.Delete); }
public void Delete(long id) { var unit_of_work = UnitOfWorkProvider.GetUnitOfWork(); unit_of_work.BeginTransaction(); FileRepository.Delete(id); unit_of_work.Commit(); }
public async Task Delete_ValidParameters_AddsFilePathParameter() { const string expected = "filePath"; var sut = new FileRepository(_requestFactory); await sut.Delete(0, expected, "branchName", "commitMessage"); _request.Received().AddParameter("file_path", expected); }
public async Task Delete_ValidParameters_AddsProjectIdUrlSegment() { const uint expected = 0; var sut = new FileRepository(_requestFactory); await sut.Delete(expected, "filePath", "branchName", "commitMessage"); _request.Received().AddUrlSegment("projectId", expected); }
public String Delete(String fileName) { var user = _userSvc.CurrentUser(); var file = _files.GetByIdUserAndLabel(user.Id, fileName); _files.Delete(file.Id); _attach.DeleteFile(file.Id); return("OK"); }
public void DeleteFileTest() { var auxFile = new File { Name = "algo.txt", Id = 1 }; fileRepository.Delete(auxFile); mockContext.Verify(e => e.SaveChanges(), Times.Once()); }
/// <summary> /// Supprime le fichier. /// </summary> /// <param name="id">Identifiant du fichier.</param> public void DeleteFile(string id) { FileModel fileModel = GetFile(id); var deleteFileRequest = new DeleteObjectRequest { BucketName = _bucketName, Key = fileModel.Key }; DeleteObjectResponse fileDeleteResponse = _amazonS3Client.DeleteObjectAsync(deleteFileRequest).Result; _fileRepository.Delete(id); }
public ActionResult Delete(int id) { if (fileRepository.Delete(id)) { return(View("Success")); } else { return(View("Fail")); } }
public IHttpActionResult Delete(int id) { var file = fileRepo.GetById(id); if (file == null) { return(Content(HttpStatusCode.NotFound, "Item does not exist")); } fileRepo.Delete(id); return(Ok()); }
public void WillReReduceAfterFileIsRemovedFromDb() { var cssPattern = new Regex(@"<link[^>]+type=""?text/css""?[^>]+>", RegexOptions.IgnoreCase); var urlPattern = new Regex(@"href=""?(?<url>[^"" ]+)""?[^ />]+[ />]", RegexOptions.IgnoreCase); new WebClient().DownloadString("http://localhost:8877/Local.html"); WaitToCreateResources(); var response = new WebClient().DownloadString("http://localhost:8877/Local.html"); var css = cssPattern.Match(response).ToString(); var url = urlPattern.Match(css).Groups["url"].Value; var id = Hasher.Hash(uriBuilder.ParseFileName(url)); var createTime = repo.SingleOrDefault <RequestReduceFile>(id).LastUpdated; repo.Delete <RequestReduceFile>(id); IntegrationFactHelper.RecyclePool(); new WebClient().DownloadString("http://localhost:8877/Local.html"); WaitToCreateResources(); new WebClient().DownloadString("http://localhost:8877/Local.html"); Assert.True(createTime < repo.SingleOrDefault <RequestReduceFile>(id).LastUpdated); }
public void Delete(int id) { var entity = statementFileRepository.Find(id); var transactionList = transactionRepository.Table.Where(q => q.FileID == id).ToList(); foreach (var transaction in transactionList) { transactionRepository.Delete(transaction); } statementFileRepository.Delete(entity); }
public async Task DeleteAsync(Guid fileId) { using (var uow = UnitOfWorkProvider.Create()) { var file = await _fileRepository.GetByIdSafely(fileId); if (file.UserId != CurrentUserProvider.Id) { throw new UnauthorizedAccessException(); } await _fileStorage.DeleteAsync(file.LocationId); _fileRepository.Delete(file); await uow.CommitAsync(); } }
public void Delete(String id) { User current = _login.CurrentUser(); if (!current.IsAdmin || id == current.Id.ToString()) { throw new Exception(); } foreach (var file in _files.GetAllByUser(current.Id).ToList()) { _files.Delete(file.Id); } foreach (var attach in _attach.GetAllByUser(current.Id).ToList()) { _attach.DeleteFile(attach.Id); } _users.Delete(Guid.Parse(id)); }
public void DeleteExistedFileID() { FileRepository repository = new FileRepository(); bool deleted = true; int fileID = FileRepository.array.FirstOrDefault().ID; Assert.IsTrue(repository.Delete(fileID)); foreach (var item in FileRepository.array) { if (item.ID == fileID) { deleted = false; } } Assert.IsTrue(deleted); }
public async Task <Player> Delete(string playerId) { Guid g = Guid.Parse(playerId); return(await _IRepo.Delete(g)); }
public virtual ActionResult Delete(string path, string filePath) { FileRepository.Delete(filePath); return(RedirectToAction("Index", "Upload", new { path })); }
public ActionResult Index(int?page, int?id, string filename, string nowdo, string path, string search) { int pag = page ?? 1; ViewData["page"] = pag; IPagedList <xiayun.Model.File> files; if (path == null) { path = "Home"; ViewData["path"] = "Home"; } else { ViewData["path"] = path; } if (id != null) { xiayun.Model.File file = fileinfo.Find(x => x.Id == id); string npath = file.FilePath + '/' + file.FileName; IEnumerable <xiayun.Model.File> filess = fileinfo.FindAll(x => x.FilePath.StartsWith(npath)); if (nowdo == "delete") { foreach (var item in filess) { fileinfo.Delete(item); } fileinfo.Delete(file); } else if (nowdo == "update") { foreach (var item in filess) { //item.FilePath.Replace("we", "nihao"); item.FilePath = item.FilePath.Replace(file.FileName, filename); item.UpTime = DateTime.Now.ToString(); fileinfo.Update(item); /* * item.FilePath.Replace("we", "he"); * item.UpTime = DateTime.Now.ToString(); * fileinfo.Update(item); */ } file.FileName = filename; file.UpTime = DateTime.Now.ToString(); fileinfo.Update(file); } fileinfo.SaveChanges(); } if (nowdo == "add") { string foldername = "新建文件夹"; int i = 0; while (true) { bool p = fileinfo.Exist(x => x.FileName == foldername + i); if (p == false) { break; } i++; } fileinfo.Add(new xiayun.Model.File { FileName = foldername + i, Belong = Session["user"].ToString(), FileExt = "folder", UpTime = DateTime.Now.ToString(), FilePath = path, }); fileinfo.SaveChanges(); } if (search != null) { files = fileinfo.GetPaged(x => x.Belong == Session["user"].ToString() & x.FileName.Contains(search), x => x.UpTime, pag, 10, false); ViewData["search"] = search; return(View(files)); } files = fileinfo.GetPaged(x => x.Belong == Session["user"].ToString() & x.FilePath == path, x => x.UpTime, pag, 10, false); return(View(files)); }
public new dynamic Delete(IEnumerable <string> ids) { foreach (string id in ids) { var search = dbSet.Find(id); if (search != null) { MessageControl message = FileRepository.Delete((int)FileType.Document, search.DocumentDir, search.DocumentName, search.DocumentType); if (message.Code == MessageCode.correct) { messages.Add(message); } else { try { dbSet.Remove(search); _Context.SaveChanges(); MessageControl messageControl = new MessageControl() { Code = MessageCode.correct, Error = false, Type = MessageType.Delete, Note = $"{name} with {Identificator} = {id} was delete with exit" }; messages.Add(messageControl); } catch (SqlException e) { MessageControl messageControl = new MessageControl() { Code = MessageCode.exception, Error = true, Type = MessageType.Exception, Note = $"{e.InnerException.InnerException.Message}" }; messages.Add(messageControl); } catch (Exception e) { MessageControl messageControl = new MessageControl() { Code = MessageCode.exception, Error = true, Type = MessageType.Exception, Note = $"{e.InnerException.InnerException.Message}" }; messages.Add(messageControl); } } } else { MessageControl messageControl = new MessageControl() { Code = MessageCode.error, Error = true, Type = MessageType.Not_Found, Note = $"{name} with {Identificator} : {id} not was found" }; messages.Add(messageControl); } } return(messages); }
public void DeleteFile(int id) { FileRepository.Delete(id); CacheRepository.Delete($"{FileCache}-{id}"); UnitOfWork.Save(); }
public E Delete(ID id) { return(Repository.Delete(id)); }
public async Task Delete_FilePathIsNull_ThrowsArgumentNullException() { var sut = new FileRepository(_requestFactory); await Assert.ThrowsAsync <ArgumentNullException>(() => sut.Delete(0, null, "branchName", "commitMessage")); }
public ActionResult Index(int?page, int?id, string filename, string nowdo, string path, string search, string attr) { int pag = page ?? 1; ViewData["page"] = pag; ViewData["attr"] = attr; IPagedList <xiayun.Model.File> files; if (path == null) { path = "Home"; ViewData["path"] = "Home"; } else { ViewData["path"] = path; } if (id != null) { xiayun.Model.File file = fileinfo.Find(x => x.Id == id); string npath = file.FilePath + '/' + file.FileName; IEnumerable <xiayun.Model.File> filess = fileinfo.FindAll(x => x.FilePath.StartsWith(npath)); if (nowdo == "delete") { foreach (var item in filess) { fileinfo.Delete(item); } fileinfo.Delete(file); } else if (nowdo == "update") { foreach (var item in filess) { //item.FilePath.Replace("we", "nihao"); item.FilePath = item.FilePath.Replace(file.FileName, filename); item.UpTime = DateTime.Now.ToString(); fileinfo.Update(item); /* * item.FilePath.Replace("we", "he"); * item.UpTime = DateTime.Now.ToString(); * fileinfo.Update(item); */ } file.FileName = filename; file.UpTime = DateTime.Now.ToString(); fileinfo.Update(file); } fileinfo.SaveChanges(); } if (nowdo == "add") { string foldername = "新建文件夹"; int i = 0; while (true) { bool p = fileinfo.Exist(x => x.FileName == foldername + i); if (p == false) { break; } i++; } fileinfo.Add(new xiayun.Model.File { FileName = foldername + i, Belong = Session["user"].ToString(), FileExt = "folder", UpTime = DateTime.Now.ToString(), FilePath = path, }); fileinfo.SaveChanges(); } if (search != null) { files = fileinfo.GetPaged(x => x.Belong == Session["user"].ToString() & x.FileName.Contains(search), x => x.UpTime, pag, 10, false); ViewData["search"] = search; return(View(files)); } if (attr != null) { string images = ".bmp,.jpg,.png,.tiff,.gif,.pcx,.tga,.exif,.fpx,.svg,.psd,.cdr,.pcd,.dxf,.ufo,.eps,.ai,.raw,.WMF"; string musics = ",.mp3,.wma,.wav,.asf,.aac,.vqf,.falc,.ape,.mid,.ogg"; string videos = ".rm,.rmvb,.mp4,.mov,.mtv,.dat,.wmv,.avi,.3gp,.amv,.dmv"; switch (attr) { case "img": files = fileinfo.GetPaged(x => x.Belong == Session["user"].ToString() & images.Contains(x.FileExt.ToLower()), x => x.UpTime, pag, 10, false); break; case "music": files = fileinfo.GetPaged(x => x.Belong == Session["user"].ToString() & musics.Contains(x.FileExt.ToLower()), x => x.UpTime, pag, 10, false); break; case "video": files = fileinfo.GetPaged(x => x.Belong == Session["user"].ToString() & videos.Contains(x.FileExt.ToLower()), x => x.UpTime, pag, 10, false); break; default: files = fileinfo.GetPaged(x => x.Belong == Session["user"].ToString(), x => x.UpTime, pag, 10, false); break; } return(View(files)); } files = fileinfo.GetPaged(x => x.Belong == Session["user"].ToString() & x.FilePath == path, x => x.UpTime, pag, 10, false); return(View(files)); }
public void DeleteWithoutID() { FileRepository repository = new FileRepository(); Assert.IsFalse(repository.Delete()); }