Inheritance: DbContext, IPAWAContext
Exemplo n.º 1
0
        public int deleteFolderChain(Folder DeleteMe)
        {
            PAWAContext db = new PAWAContext();
            AlbumGrid toolbelt = new AlbumGrid(dbContext);
            IEnumerable<Folder> listOfInternalFolders = toolbelt.GetFolders(DeleteMe.FolderID);
            IEnumerable<PAWA.Models.File> listOfInternalFiles = toolbelt.GetFiles(DeleteMe.FolderID);

            int nFolderDel = 0;
            int lengthOfInternalFolders;

            if (listOfInternalFolders.Count() > 0)
            {
                lengthOfInternalFolders = listOfInternalFolders.Count();
            }
            else
            {
                lengthOfInternalFolders = 0;
            }

            for (int i = 0; i < lengthOfInternalFolders; i++)
            {
                Folder delFolder = listOfInternalFolders.ElementAt(0);
                nFolderDel += deleteFolderChain(delFolder);
            }

            deleteMultipleFiles(listOfInternalFiles);
            dbContext.Folders.Remove(DeleteMe);
            dbContext.SaveChanges();
            return nFolderDel;
        }
Exemplo n.º 2
0
        public void createFolder(string FolderName, int? InFolderID)
        {
            PAWAContext db = new PAWAContext();
            if (FolderName == null)
            {
                FolderName = "Folder";
            }
            if (InFolderID == -1)
            {
                InFolderID = null;
            }

            var newFolder = new PAWA.Models.Folder
            {
                CreateDateTime = System.DateTime.Now,
                FolderName = FolderName,
                InFolderID = InFolderID,
                UserID = WebSecurity.CurrentUserId,

                //FolderID auto?

            };

            db.Folders.Add(newFolder);
            db.SaveChanges();
        }
Exemplo n.º 3
0
 public int GetID(string filename)
 {
     int value = 0;
     PAWAContext dbContext = new PAWAContext();
     var identifier = from f in dbContext.Files
                      where f.Filename == filename
                      select f.FileID;
     value = identifier.SingleOrDefault();
     return value;
 }
Exemplo n.º 4
0
 public string GetFilename(int ID)
 {
     string value = "";
     PAWAContext dbContext = new PAWAContext();
     var identifier = from f in dbContext.Files
                      where f.FileID == ID
                      select f.Filename;
     value = identifier.SingleOrDefault();
     return value;
 }
Exemplo n.º 5
0
        public ActionResult EditTag([Bind(Include = "TagsID, TagName, Status, UserSuggest")]Models.Tags tag)
        {
            PAWAContext db = new PAWAContext();
            db.Tags.Attach(tag);
            var entry = db.Entry(tag);

            entry.Property(e => e.TagName).IsModified = true;
            entry.Property(e => e.Status).IsModified = true;
            entry.Property(e => e.UserSuggest).IsModified = true;

            db.SaveChanges();
            return RedirectToAction("TagManagement");
        }
Exemplo n.º 6
0
 public HomeController()
 {
     dbContext = new PAWAContext();
 }
Exemplo n.º 7
0
        public int? getParentID(int? folderId)
        {
            int? returnValue = folderId;
            PAWAContext db = new PAWAContext();
            Tools toolBelt = new Tools();
            IList<PAWA.Models.Folder> foldermonkey = toolBelt.getFolders(1);
            if (folderId != null)
            {
                for (int i = 0; i < foldermonkey.Count; i++)
                {
                    if (foldermonkey[i].FolderID == folderId)
                    {
                        returnValue = foldermonkey[i].InFolderID;
                    }
                }

            }
            return returnValue;
        }
Exemplo n.º 8
0
 /// <summary>
 /// Gets all users
 /// </summary>
 public IEnumerable<PAWA.Models.User> GetUsers()
 {
     PAWAContext db = new PAWAContext();
     var users = from u in db.Users
                 select u;
     return users;
 }
Exemplo n.º 9
0
        ///<summary>
        /// Used to insert tags into the DB
        ///</summary>
        public void createTag(string name, string type)
        {
            if (type == "user")
            {
                //db = new PAWAContext();
                var newTag = new PAWA.Models.Tags
                {

                    FirstDateTime = System.DateTime.Now,
                    Status = Models.Status.Active,
                    TagName = name,
                    UseCount = 1,
                    UserSuggest = Models.UserSuggest.User
                };
                db.Tags.Add(newTag);
                db.SaveChanges();
            }
            else if (type == "admin")
            {
                PAWAContext db = new PAWAContext();
                var newTag = new PAWA.Models.Tags
                {
                    FirstDateTime = System.DateTime.Now,
                    Status = Models.Status.Active,
                    TagName = name,
                    UseCount = 0,
                    UserSuggest = Models.UserSuggest.Suggested
                };
                db.Tags.Add(newTag);
                db.SaveChanges();
            }
        }
Exemplo n.º 10
0
        public int GetSubFolders(int FolderID)
        {
            var UserID = WebSecurity.CurrentUserId;

                int returnValue = FolderID;
                PAWAContext db = new PAWAContext();
                Tools toolbelt = new Tools();
                IList<PAWA.Models.Folder> foldermodel = toolbelt.getFolders(UserID);

                for (int i =0; i < foldermodel.Count; i++)
                {
                    if (foldermodel.ElementAt(i).InFolderID == FolderID)
                    {
                        returnValue = foldermodel.ElementAt(i).FolderID;
                    }
                }
                return returnValue;
        }