public LmPlatformRepositoriesContainer()
 {
     UsersRepository                   = new UsersRepository(_dataContext);
     BugsRepository                    = new BugsRepository(_dataContext);
     BugLogsRepository                 = new BugLogsRepository(_dataContext);
     GroupsRepository                  = new GroupsRepository(_dataContext);
     ProjectsRepository                = new ProjectsRepository(_dataContext);
     ProjectUsersRepository            = new ProjectUsersRepository(_dataContext);
     ProjectCommentsRepository         = new ProjectCommentsRepository(_dataContext);
     StudentsRepository                = new StudentsRepository(_dataContext);
     SubjectRepository                 = new SubjectRepository(_dataContext);
     TestsRepository                   = new TestsRepository(_dataContext);
     TestUnlocksRepository             = new TestUnlockRepository(_dataContext);
     QuestionsRepository               = new QuestionsRepository(_dataContext);
     UsersRepository                   = new UsersRepository(_dataContext);
     ModulesRepository                 = new ModulesRepository(_dataContext);
     LecturerRepository                = new LecturerRepository(_dataContext);
     MessageRepository                 = new MessageRepository(_dataContext);
     MaterialsRepository               = new MaterialsRepository(_dataContext);
     FoldersRepository                 = new FoldersRepository(_dataContext);
     SubGroupRepository                = new SubGroupRepository(_dataContext);
     AttachmentRepository              = new AttachmentRepository(_dataContext);
     LecturesRepository                = new LecturesRepository(_dataContext);
     LabsRepository                    = new LabsRepository(_dataContext);
     ProjectUsersRepository            = new ProjectUsersRepository(_dataContext);
     PracticalRepository               = new PracticalRepository(_dataContext);
     ConceptRepository                 = new ConceptRepository(_dataContext);
     WatchingTimeRepository            = new WatchingTimeRepository(_dataContext);
     TestQuestionPassResultsRepository = new TestQuestionPassResultsRepository(_dataContext);
     //todo UNUSED ProjectMatrixRequirementsRepository = new ProjectMatrixRequirementsRepository(_dataContext);
 }
Esempio n. 2
0
 public FolderModel(ClubRepository clubRepo, FoldersRepository foldersRepo, OgmaConfig config, StoriesRepository storiesRepo)
 {
     _clubRepo    = clubRepo;
     _foldersRepo = foldersRepo;
     _config      = config;
     _storiesRepo = storiesRepo;
 }
 /// <summary>
 /// Check username and token which provided are allowed and return Folder as result for later on
 /// </summary>
 /// <param name="username"></param>
 /// <param name="token"></param>
 /// <returns></returns>
 private Folder ValidPermissionV2(string username, string token)
 {
     if (username != null && token != null)
     {
         Folder folder = new FoldersRepository().GetByToken(token);
         physicalPath = folder.Path;
         return(folder);
     }
     return(null);
 }
        public HttpResponseMessage RemoveFolder(string name)
        {
            HttpResponseMessage result = null;
            var    httpRequest         = HttpContext.Current.Request;
            string username            = httpRequest.Params.Get("username");
            string token = httpRequest.Params.Get("token");//token of delete path

            Folder currFolder = ValidPermissionV2(username, token);

            if (currFolder == null)
            {
                return(Request.CreateResponse(HttpStatusCode.Unauthorized, "Permission Denied"));
            }
            string path = physicalPath;

            try
            {
                // Determine whether the directory exists.
                if (!Directory.Exists(path))
                {
                    result = Request.CreateResponse(HttpStatusCode.OK, "Not Existed Folder");
                }

                bool isDeleted = new FoldersRepository().RemoveRecord(currFolder);
                if (isDeleted)
                {
                    // Delete the directory.
                    Directory.Delete(path);
                    result = Request.CreateResponse(HttpStatusCode.OK, "Remove Successfully");
                    LogAction(username, token, ActionType.Delete, path);
                }
                else
                {
                    //Can't delete in DB --> no delete directory
                    result = Request.CreateResponse(HttpStatusCode.ExpectationFailed, "Accepted. But failed to remove folder!");
                }
            }
            catch (Exception e)
            {
                result = Request.CreateResponse(HttpStatusCode.InternalServerError, e.ToString());
            }

            return(result);
        }
 /// <summary>
 /// Check username and token which provided are allowed and return boolean as result
 /// </summary>
 /// <param name="username"></param>
 /// <param name="token"></param>
 /// <returns></returns>
 private bool ValidPermission(string username, string token)
 {
     if (username != null && token != null)
     {
         Folder folder = new FoldersRepository().GetByToken(token);
         if (folder == null)
         {
             return(false);
         }
         physicalPath = folder.Path;
         if (folder.Brand != null)
         {
             if (new CredentialsRepository().CheckUserBrand(username, folder.Brand))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        public HttpResponseMessage CreateFolder(string name)
        {
            HttpResponseMessage result = null;
            var    httpRequest         = HttpContext.Current.Request;
            string username            = httpRequest.Params.Get("username");
            string token = httpRequest.Params.Get("token");// token of parentPath

            Folder currFolder = ValidPermissionV2(username, token);

            if (currFolder == null)
            {
                return(Request.CreateResponse(HttpStatusCode.Unauthorized, "Permission Denied"));
            }
            string path = physicalPath + "\\" + name;

            try
            {
                // Determine whether the directory exists.
                if (Directory.Exists(path))
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, "Existed Folder"));
                }

                // Try to create the directory.
                DirectoryInfo di       = Directory.CreateDirectory(path);
                string        newToken = new FoldersRepository().InsertNew(currFolder.Brand, path, currFolder.Id);
                result = Request.CreateResponse(HttpStatusCode.OK, "Create Successfully. New folder's token: " + newToken);

                LogAction(username, token, ActionType.Create, path);
            }
            catch (Exception e)
            {
                result = Request.CreateResponse(HttpStatusCode.InternalServerError, e.ToString());
            }

            return(result);
        }
Esempio n. 7
0
 public IndexModel(ClubRepository clubRepo, FoldersRepository foldersRepo)
 {
     _clubRepo    = clubRepo;
     _foldersRepo = foldersRepo;
 }
Esempio n. 8
0
 public FoldersController(FoldersRepository foldersRepo, ApplicationDbContext context)
 {
     _foldersRepo = foldersRepo;
     _context     = context;
 }