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