Exemplo n.º 1
0
        public FileDB SaveFile(FileDB file, string action)
        {
            FileManagerDAL fmDAL = new FileManagerDAL();
            FileDB         target;

            if (file.FileId != 0)
            {
                target = fmDAL.Files.Find(file.FileId);
            }
            else
            {
                target = file;
            }

            switch (action)
            {
            case "upload":
            {
                target.UploadTime   = DateTime.Now;
                target.ModifiedTime = DateTime.Now;
                target.Version      = 1;
                target.FormerId     = null;

                fmDAL.Entry(target).State = EntityState.Added;
                break;
            }

            case "mark delete":
            {
                target.isDelete     = true;
                target.ModifiedTime = DateTime.Now;

                fmDAL.Entry(target).State = EntityState.Modified;
                break;
            }

            case "delete":
            {
                target.FilePath     = null;
                target.ModifiedTime = DateTime.Now;

                fmDAL.Entry(target).State = EntityState.Modified;
                break;
            }

            case "modify":
            {
                file.UploadTime   = target.UploadTime;
                file.ModifiedTime = DateTime.Now;
                file.FormerId     = target;
                target.isDelete   = true;

                fmDAL.Entry(file).State   = EntityState.Added;
                fmDAL.Entry(target).State = EntityState.Modified;
                break;
            }
            }
            fmDAL.SaveChanges();
            return(file);
        }
Exemplo n.º 2
0
        public UserProfile ModifyUser(UserProfile user)
        {
            FileManagerDAL fmDAL = new FileManagerDAL();

            fmDAL.Entry(user).State = EntityState.Modified;
            fmDAL.SaveChanges();
            return(user);
        }