public void AddDirAndFile() { var dir = new BackedUpDirectory() { Modified = DateTime.Now, Name = @"c:\root1" }; _dbService.AddDirectory(dir); var file1 = new BackedUpFile() { Name = "file1", ParentId = dir.Id, Modified = DateTime.Now }; _dbService.AddFile(file1); var dir2 = _dbService.GetDirectory(@"c:\root1"); Assert.True(dir.Equals(dir2)); var file2 = _dbService.GetFile("file1", dir.Id); Assert.True(file1.Id == file2.Id); }
public IActionResult Add([FromBody] BackedUpDirectory directory) { if (directory == null) { return(BadRequest()); } try { _dbService.AddDirectory(directory); } catch (Exception ex) { return(BadRequest(ex)); } return(Json(directory)); }
public ActionResult CreateDir(string dirName, string parentMenuId) { _myDatabaseService.AddDirectory(dirName, int.Parse(parentMenuId)); _myDatabaseService.SaveChanges(); return(RedirectToAction("Index")); }