コード例 #1
0
        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);
        }
コード例 #2
0
        public IActionResult Add([FromBody] BackedUpDirectory directory)
        {
            if (directory == null)
            {
                return(BadRequest());
            }

            try
            {
                _dbService.AddDirectory(directory);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
            return(Json(directory));
        }
コード例 #3
0
 public ActionResult CreateDir(string dirName, string parentMenuId)
 {
     _myDatabaseService.AddDirectory(dirName, int.Parse(parentMenuId));
     _myDatabaseService.SaveChanges();
     return(RedirectToAction("Index"));
 }