示例#1
0
 private bool CheckProjectConsistency(UrlConfig config)
 {
     try
     {
         return(_DbManager.ProjetsContext.Find(config.IdProject) != null);
     } catch
     {
         return(false);
     }
 }
示例#2
0
 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
 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
 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
 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
 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
        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
        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
 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
 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
        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
 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
 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
 public UserEntity Update(UserEntity entity, UrlConfig config)
 {
     throw new NotImplementedException();
 }
示例#26
0
 public List <UserEntity> Remove(UrlConfig config)
 {
     throw new NotImplementedException();
 }