コード例 #1
0
 private bool CheckProjectConsistency(UrlConfig config)
 {
     try
     {
         return(_DbManager.ProjetsContext.Find(config.IdProject) != null);
     } catch
     {
         return(false);
     }
 }
コード例 #2
0
ファイル: ProjectService.cs プロジェクト: LaurainClem/Tuesday
 public ProjectEntity FindOne(UrlConfig config)
 {
     try
     {
         return(_Context.ProjetsContext.Single(project => project.Id == config.IdProject));
     } catch
     {
         __logger.LogError($"Error while trying to retrieve project ${config.IdProject}");
         throw new HttpNotFoundException();
     }
 }
コード例 #3
0
ファイル: ProjectService.cs プロジェクト: LaurainClem/Tuesday
 public List <ProjectEntity> FindAll(UrlConfig config)
 {
     try
     {
         return(_Context.ProjetsContext.ToList());
     } catch
     {
         __logger.LogError("Error while trying to retrieve projects");
         throw new HttpInternalErrorException("Error while trying to retrieve projects");
     }
 }
コード例 #4
0
ファイル: UserService.cs プロジェクト: LaurainClem/Tuesday
 public List <UserEntity> FindAll(UrlConfig config)
 {
     try
     {
         return(_DbManager.UsersContext.ToList());
     } catch
     {
         __logger.LogError("An error occured while trying to retrieve users");
         throw new HttpInternalErrorException("An error occured while trying to retrieve users");
     }
 }
コード例 #5
0
ファイル: UserService.cs プロジェクト: LaurainClem/Tuesday
 public UserEntity FindOne(UrlConfig config)
 {
     try
     {
         return(_DbManager.UsersContext.Find(config.IdUser));
     }
     catch
     {
         __logger.LogInformation($"Error while trying to retrieve user with id {config.IdUser}");
         throw new HttpNotFoundException();
     }
 }
コード例 #6
0
        public bool IsUrlValid(UrlConfig config)
        {
            if (config.IdProject != 0 && CheckProjectConsistency(config))
            {
                if (config.IdJalon != 0)
                {
                    return(CheckJalonConsistency(config));
                }

                return(true);
            }
            __logger.LogInformation("Url invalid no project id found or can't retrieve project");
            return(false);
        }
コード例 #7
0
ファイル: ProjectService.cs プロジェクト: LaurainClem/Tuesday
 public List <ProjectEntity> Remove(UrlConfig config)
 {
     try
     {
         _Context.ProjetsContext.Remove(FindOne(config));
         _Context.SaveChanges();
         return(FindAll(config));
     }
     catch
     {
         __logger.LogError($"Error while trying to remove project ${config.IdProject}");
         throw new HttpInternalErrorException($"Error while trying to remove project ${config.IdProject}");
     }
 }
コード例 #8
0
ファイル: ProjectService.cs プロジェクト: LaurainClem/Tuesday
        public ProjectEntity Add(ProjectEntity entity, UrlConfig config)
        {
            try
            {
                _Context.ProjetsContext.Add(entity);
                _Context.SaveChanges();

                return(entity);
            }
            catch
            {
                __logger.LogError($"Error while trying to add {entity}");
                throw new HttpInternalErrorException($"Error while trying to add {entity}");
            }
        }
コード例 #9
0
ファイル: TaskService.cs プロジェクト: LaurainClem/Tuesday
        public void UpdateJalon(UrlConfig config)
        {
            try
            {
                JalonEntity jalon = _DbManager.JalonsContext.Find(config.IdJalon);
                jalon.PlannedStartDate = _DbManager.TasksContext.Where(t => t.JalonId == config.IdJalon).OrderBy(t => t.PlannedStartDate).First().PlannedStartDate;
                jalon.PlannedEndDate   = _DbManager.TasksContext.Where(t => t.JalonId == config.IdJalon).OrderByDescending(t => t.PlannedEndDate).First().PlannedEndDate;
                jalon.RealStartDate    = _DbManager.TasksContext.Where(t => t.JalonId == config.IdJalon).OrderBy(t => t.RealStartDate).First().RealStartDate;
                jalon.RealEndDate      = _DbManager.TasksContext.Where(t => t.JalonId == config.IdJalon).OrderByDescending(t => t.RealEndDate).First().RealEndDate;

                _DbManager.JalonsContext.Update(jalon);
                _DbManager.SaveChanges();
                _JalonService.UpdateProject(config);
            } catch {
                __logger.LogError($"Error while trying to update jalon {config.IdJalon}");
                throw new HttpInternalErrorException($"Error while trying to update jalon {config.IdJalon}");
            }
        }
コード例 #10
0
 private bool CheckJalonConsistency(UrlConfig config)
 {
     try
     {
         var jalon = _DbManager.JalonsContext.Find(config.IdJalon);
         if (jalon == null || jalon.ProjectId != config.IdProject)
         {
             __logger.LogInformation($"Url invalid no jalon found with id {config.IdJalon} in project {config.IdProject}");
             return(false);
         }
         return(jalon.ProjectId == config.IdProject);
     }
     catch
     {
         __logger.LogInformation($"Url invalid no jalon found with id {config.IdJalon}");
         return(false);
     }
 }
コード例 #11
0
 public ExigenceEntity FindOne(UrlConfig config)
 {
     if (_ConsistencyChecker.IsUrlValid(config))
     {
         try
         {
             return(_DbManager.ExigencesContext.Find(config.IdExigence));
         }
         catch
         {
             __logger.LogInformation($"Error occured while trying find Exigence ${config.IdExigence} of Jalon {config.IdJalon}");
             throw new HttpNotFoundException();
         }
     }
     else
     {
         throw new HttpUrlNotValidException();
     }
 }
コード例 #12
0
 public List <ExigenceEntity> FindAll(UrlConfig config)
 {
     if (_ConsistencyChecker.IsUrlValid(config))
     {
         try
         {
             return(_DbManager.ExigencesContext.Where(exigence => exigence.ProjectId == config.IdProject).ToList());
         }
         catch
         {
             __logger.LogInformation($"Error occured while trying find Exigences of project {config.IdProject}");
             throw new HttpInternalErrorException($"Error occured while trying find Exigences of project {config.IdProject}");
         }
     }
     else
     {
         throw new HttpUrlNotValidException();
     }
 }
コード例 #13
0
 public List <JalonEntity> FindAll(UrlConfig config)
 {
     if (_ConsistencyChecker.IsUrlValid(config))
     {
         try
         {
             return(_DbManager.JalonsContext.Where(jalon => jalon.ProjectId == config.IdProject).ToList());
         }
         catch
         {
             __logger.LogError("Error while trying to retrieve jalons");
             throw new HttpInternalErrorException("Error while trying to retrieve jalons");
         }
     }
     else
     {
         throw new HttpUrlNotValidException();
     }
 }
コード例 #14
0
 public JalonEntity FindOne(UrlConfig config)
 {
     if (_ConsistencyChecker.IsUrlValid(config))
     {
         try
         {
             return(_DbManager.JalonsContext.Find(config.IdJalon));
         }
         catch
         {
             __logger.LogError($"Error while trying to retrieve jalon ${config.IdJalon} in project ${config.IdProject}");
             throw new HttpNotFoundException();
         }
     }
     else
     {
         throw new HttpUrlNotValidException();
     }
 }
コード例 #15
0
        public void UpdateProject(UrlConfig config)
        {
            try
            {
                ProjectEntity project = _DbManager.ProjetsContext.Find(config.IdProject);
                project.PlannedStartDate = _DbManager.JalonsContext.Where(p => p.ProjectId == config.IdProject).OrderBy(p => p.PlannedStartDate).First().PlannedStartDate;
                project.PlannedEndDate   = _DbManager.JalonsContext.Where(p => p.ProjectId == config.IdProject).OrderByDescending(p => p.PlannedEndDate).First().PlannedEndDate;
                project.RealStartDate    = _DbManager.JalonsContext.Where(p => p.ProjectId == config.IdProject).OrderBy(p => p.RealStartDate).First().RealStartDate;
                project.RealEndDate      = _DbManager.JalonsContext.Where(p => p.ProjectId == config.IdProject).OrderByDescending(p => p.RealEndDate).First().RealEndDate;

                _DbManager.ProjetsContext.Update(project);
                _DbManager.SaveChanges();
            }
            catch
            {
                __logger.LogError($"Error while trying to update jalon {config.IdJalon}");
                throw new HttpInternalErrorException($"Error while trying to update jalon {config.IdJalon}");
            }
        }
コード例 #16
0
ファイル: TaskService.cs プロジェクト: LaurainClem/Tuesday
 public TaskEntity FindOne(UrlConfig config)
 {
     if (_ConsistencyChecker.IsUrlValid(config))
     {
         try
         {
             return(_DbManager.TasksContext.Find(config.IdTask));
         }
         catch
         {
             __logger.LogError($"Error while trying to retrieve task {config.IdJalon} in jalon {config.IdJalon}");
             throw new HttpNotFoundException();
         }
     }
     else
     {
         throw new HttpUrlNotValidException();
     }
 }
コード例 #17
0
ファイル: TaskService.cs プロジェクト: LaurainClem/Tuesday
 public List <TaskEntity> FindAll(UrlConfig config)
 {
     if (_ConsistencyChecker.IsUrlValid(config))
     {
         try
         {
             return(_DbManager.TasksContext.Where(task => task.JalonId == config.IdJalon).ToList());
         }
         catch
         {
             __logger.LogError("Error while trying to retrieve tasks");
             throw new HttpInternalErrorException("Error while trying to retrieve tasks");
         }
     }
     else
     {
         throw new HttpUrlNotValidException();
     }
 }
コード例 #18
0
ファイル: ProjectService.cs プロジェクト: LaurainClem/Tuesday
        public ProjectEntity Update(ProjectEntity entity, UrlConfig config)
        {
            try
            {
                _Context.ProjetsContext.Update(entity);
                _Context.SaveChanges();

                UrlConfig newConfig = new UrlConfig()
                {
                    IdProject = entity.Id
                };

                return(FindOne(config));
            } catch
            {
                __logger.LogError($"Error while trying to update project ${config.IdProject}");
                throw new HttpInternalErrorException($"Error while trying to update project ${config.IdProject}");
            }
        }
コード例 #19
0
 public JalonEntity Add(JalonEntity entity, UrlConfig config)
 {
     if (_ConsistencyChecker.IsUrlValid(config))
     {
         try
         {
             _DbManager.JalonsContext.Add(entity);
             _DbManager.SaveChanges();
             return(entity);
         } catch
         {
             __logger.LogError($"Error while trying to add {entity}");
             throw new HttpInternalErrorException($"Error while trying to add {entity}");
         }
     }
     else
     {
         throw new HttpUrlNotValidException();
     }
 }
コード例 #20
0
 public ExigenceEntity Update(ExigenceEntity entity, UrlConfig config)
 {
     if (_ConsistencyChecker.IsUrlValid(config))
     {
         try
         {
             _DbManager.ExigencesContext.Update(entity);
             _DbManager.SaveChanges();
             return(entity);
         }
         catch
         {
             __logger.LogInformation($"Error occured while trying to update {entity} of jalon {config.IdJalon}");
             throw new HttpInternalErrorException($"Error occured while trying to update {entity} of jalon {config.IdJalon}");
         }
     }
     else
     {
         throw new HttpUrlNotValidException();
     }
 }
コード例 #21
0
 public List <ExigenceEntity> Remove(UrlConfig config)
 {
     if (_ConsistencyChecker.IsUrlValid(config))
     {
         try
         {
             _DbManager.ExigencesContext.Remove(FindOne(config));
             _DbManager.SaveChanges();
             return(FindAll(config));
         }
         catch
         {
             __logger.LogInformation($"Error occured while trying to remove exigence with id {config.IdExigence} of project {config.IdProject}");
             throw new HttpInternalErrorException($"Error occured while trying to remove exigence with id {config.IdExigence} of project {config.IdProject}");
         }
     }
     else
     {
         throw new HttpUrlNotValidException();
     }
 }
コード例 #22
0
ファイル: TaskService.cs プロジェクト: LaurainClem/Tuesday
 public TaskEntity Update(TaskEntity entity, UrlConfig config)
 {
     if (_ConsistencyChecker.IsUrlValid(config))
     {
         try
         {
             _DbManager.TasksContext.Update(entity);
             _DbManager.SaveChanges();
             UpdateJalon(config);
             return(entity);
         }
         catch
         {
             __logger.LogError($"Error while trying to update task {config.IdTask}");
             throw new HttpInternalErrorException($"Error while trying to update task {config.IdTask}");
         }
     }
     else
     {
         throw new HttpUrlNotValidException();
     }
 }
コード例 #23
0
 public ExigenceEntity Add(ExigenceEntity entity, UrlConfig config)
 {
     if (_ConsistencyChecker.IsUrlValid(config))
     {
         try
         {
             entity.ProjectId = config.IdProject;
             _DbManager.ExigencesContext.Add(entity);
             _DbManager.SaveChanges();
             return(entity);
         }
         catch
         {
             __logger.LogInformation($"Error occured while trying to add {entity}");
             throw new HttpInternalErrorException($"Error occured while trying to add {entity}");
         }
     }
     else
     {
         throw new HttpUrlNotValidException();
     }
 }
コード例 #24
0
ファイル: TaskService.cs プロジェクト: LaurainClem/Tuesday
 public List <TaskEntity> Remove(UrlConfig config)
 {
     if (_ConsistencyChecker.IsUrlValid(config))
     {
         try
         {
             _DbManager.TasksContext.Remove(FindOne(config));
             _DbManager.SaveChanges();
             config.IdTask = 0;
             return(FindAll(config));
         }
         catch
         {
             __logger.LogError($"Error while trying to remove task {config.IdTask} of jalon {config.IdJalon}");
             throw new HttpInternalErrorException($"Error while trying to remove task {config.IdTask} of jalon {config.IdJalon}");
         }
     }
     else
     {
         throw new HttpUrlNotValidException();
     }
 }
コード例 #25
0
ファイル: UserService.cs プロジェクト: LaurainClem/Tuesday
 public UserEntity Update(UserEntity entity, UrlConfig config)
 {
     throw new NotImplementedException();
 }
コード例 #26
0
ファイル: UserService.cs プロジェクト: LaurainClem/Tuesday
 public List <UserEntity> Remove(UrlConfig config)
 {
     throw new NotImplementedException();
 }