Example #1
0
 public void AddFolder(Folder folder)
 {
     try
     {
         DB.AddToFolders(folder);
     }
     catch (Exception)
     {
         throw new Exception("Lỗi thêm thư mục");
     }
 }
Example #2
0
 public void AccessFolder(Folder folder)
 {
     try
     {
         var existringFolder = DB.Folders.First(f => f.ID == folder.ID);
         existringFolder.LastAccessOnDate = folder.LastAccessOnDate;
         existringFolder.LastAccessByUserID = folder.LastAccessByUserID;
         CommitChanges();
     }
     catch (Exception)
     {
         throw new Exception("Lỗi cập nhật ngày truy cập");
     }
 }
Example #3
0
        public ActionResult CreateNewFolder(FolderModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return RedirectToAction("Error", "Base", new { eID = 0 });
                }

                var folder = new Folder
                                 {
                                     FolderName = model.FolderName,
                                     ParentID = model.ParentID,
                                     IsDeleted = 0,
                                     Description = model.Description,
                                     IsPublic = model.IsPublic,
                                     Keywords = model.Keywords,
                                     CreatedByUserID = int.Parse(User.Identity.Name),
                                     CreatedOnDate = DateTime.Now
                                 };
                var parentFolder = _repository.FindFolderByID(folder.ParentID.Value);
                if (string.IsNullOrEmpty(parentFolder.Path))
                {
                    folder.Path = parentFolder.FolderName + @"\";
                }
                else
                {
                    folder.Path = parentFolder.Path + parentFolder.FolderName + @"\";
                }

                string dir = _root + folder.Path + folder.FolderName;

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                    _repository.AddFolder(folder);
                    _repository.CommitChanges();
                }
                else
                {
                    return RedirectToAction("Error", new { eID = 4 });
                }

                return RedirectToAction("ShowFolder", new { folderID = folder.ParentID });
            }
            catch (Exception)
            {
                return RedirectToAction("Error", new {eID = 0});
            }
        }
Example #4
0
 public void UpdateFolder(Folder folder)
 {
     try
     {
         var existringFolder = DB.Folders.First(f => f.ID == folder.ID);
         existringFolder.FolderName = folder.FolderName;
         existringFolder.IsPublic = folder.IsPublic;
         existringFolder.Description = folder.Description;
         existringFolder.Keywords = folder.Keywords;
         existringFolder.LastModifiedByUserID = folder.LastModifiedByUserID;
         existringFolder.LastModifiedOnDate = folder.LastModifiedOnDate;
     }
     catch (Exception)
     {
         throw new Exception("Lỗi cập nhật thư mục");
     }
 }
Example #5
0
 /// <summary>
 /// Create a new Folder object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="folderName">Initial value of the FolderName property.</param>
 /// <param name="isDeleted">Initial value of the IsDeleted property.</param>
 public static Folder CreateFolder(global::System.Int32 id, global::System.String folderName, global::System.Int32 isDeleted)
 {
     Folder folder = new Folder();
     folder.ID = id;
     folder.FolderName = folderName;
     folder.IsDeleted = isDeleted;
     return folder;
 }
Example #6
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Folders EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToFolders(Folder folder)
 {
     base.AddObject("Folders", folder);
 }