/// <summary> /// Returns a project by id /// </summary> /// <param name="projectId">The project id</param> /// <returns>Project</returns> public ProjectDTO GetProjectById(int projectId) { var project = ProjectQueries.CreateGetProjectByIdQuery(this.Context, projectId).FirstOrDefault(); this.logger.Trace("Retrieved project by id {0}.", projectId); return(project); }
/// <summary> /// Returns all projects, sorted, filtered, and paged within the eca system. /// </summary> /// <param name="queryOperator">The query operator.</param> /// <returns>The paged, filtered, and sorted projects.</returns> public async Task <PagedQueryResults <SimpleProjectDTO> > GetProjectsAsync(QueryableOperator <SimpleProjectDTO> queryOperator) { var projects = await ProjectQueries.CreateGetProjectsQuery(this.Context, queryOperator).ToPagedQueryResultsAsync(queryOperator.Start, queryOperator.Limit); this.logger.Trace("Retrieved projects by query operator {0}.", queryOperator); return(projects); }
/// <summary> /// Returns the sorted, filtered, and paged projects in the program with the given program id. /// </summary> /// <param name="programId">The program id.</param> /// <param name="queryOperator">The query operator.</param> /// <returns>The paged, filtered, and sorted projects.</returns> public Task <PagedQueryResults <SimpleProjectDTO> > GetProjectsByProgramIdAsync(int programId, QueryableOperator <SimpleProjectDTO> queryOperator) { var projects = ProjectQueries.CreateGetProjectsByProgramQuery(this.Context, programId, queryOperator).ToPagedQueryResultsAsync(queryOperator.Start, queryOperator.Limit); this.logger.Trace("Retrieved projects by program id {0} and query operator {1}.", programId, queryOperator); return(projects); }
/// <summary> /// Returns projects by person id /// </summary> /// <param name="personId">The person id</param> /// <param name="queryOperator">The query operator</param> /// <returns>Projects by person id</returns> public Task <PagedQueryResults <ParticipantTimelineDTO> > GetProjectsByPersonIdAsync(int personId, QueryableOperator <ParticipantTimelineDTO> queryOperator) { var projects = ProjectQueries.CreateGetProjectsByPersonIdQuery(this.Context, personId, queryOperator).ToPagedQueryResultsAsync(queryOperator.Start, queryOperator.Limit); this.logger.Trace("Retrieved projects by person id {0} and query operator {1}.", personId, queryOperator); return(projects); }
public async Task <IActionResult> GetInfosProject(int idProject) { ProjectStudentTable projectTable = _stObjMap.StObjs.Obtain <ProjectStudentTable>(); SqlDefaultDatabase db = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>(); using (var ctx = new SqlStandardCallContext()) { ProjectQueries projectQueries = new ProjectQueries(ctx, db); ProjectDetailsData projectDetails = new ProjectDetailsData { Project = await projectQueries.GetDetailProject(idProject), Students = await projectQueries.GetAllUsersOfProject(idProject) }; List <string> listGroups = await projectQueries.GetGroupsOfProject(idProject); listGroups = listGroups.FindAll(x => x.StartsWith("S0") || x == "IL" || x == "SR"); string groups = listGroups[0]; if (listGroups.Count >= 2) { for (int i = 1; i < listGroups.Count; i++) { groups += "-" + listGroups[i]; } } projectDetails.Project.Semester = groups; return(Ok(projectDetails)); } }
public async Task <IActionResult> GetAllGradeProject() { SqlDefaultDatabase db = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>(); int userId = _authenticationInfo.ActualUser.UserId; using (var ctx = new SqlStandardCallContext()) { ProjectQueries projectQueries = new ProjectQueries(ctx, db); TimedPeriodQueries timedPeriodQueries = new TimedPeriodQueries(ctx, db); TimedUserQueries timedUserQueries = new TimedUserQueries(ctx, db); UserQueries userQueries = new UserQueries(ctx, db); GroupQueries groupQueries = new GroupQueries(ctx, db); GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId); AclQueries aclQueries = new AclQueries(ctx, db); if (await aclQueries.VerifyGrantLevelByUserId(112, await aclQueries.GetAclIdBySchoolId(groupData.ParentZoneId), userId, Operator.SuperiorOrEqual) == false) { Result result = new Result(Status.Unauthorized, "Vous n'etes pas autorisé à utiliser cette fonctionnalité !"); return(this.CreateResult(result)); } List <ProjectInfosJuryData> projects = await projectQueries.getAllProjectsGrade(groupData.ZoneId); List <ProjectForumResultData> listToSend = GetProjectsOfForum(projects); return(Ok(listToSend)); } }
public async Task <List <Project> > GetAllProjects() { int userId = _authenticationInfo.ActualUser.UserId; var sqlDatabase = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>(); List <Project> projectList = new List <Project>(); using (var ctx = new SqlStandardCallContext()) { ProjectQueries projectQueries = new ProjectQueries(ctx, sqlDatabase); GroupQueries groupQueries = new GroupQueries(ctx, sqlDatabase); GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId); IEnumerable <ProjectData> projects = await projectQueries.GetAllProjectByForum(groupData.ZoneId); foreach (ProjectData project in projects) { List <string> listGroups = await projectQueries.GetGroupsOfProject(project.ProjectStudentId); listGroups = listGroups.FindAll(x => x.StartsWith("S0") || x == "IL" || x == "SR"); project.Semester = string.Join("-", listGroups.ToArray()); if (listGroups[0] == "IL") { project.Semester = string.Join("-", listGroups.ToArray().Reverse()); } Project p = new Project(project.ProjectStudentId, project.Name, project.Semester, project.CoordinatesX, project.CoordinatesY, project.ClassRoom, project.Height, project.Width, project.ForumNumber); projectList.Add(p); } } return(projectList); }
public async Task <IActionResult> DownloadExcel( ) { var sqlDatabase = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>(); ExcelUtilis excel = new ExcelUtilis(); int userId = _authenticationInfo.ActualUser.UserId; using (var ctx = new SqlStandardCallContext()) { GroupQueries groupQueries = new GroupQueries(ctx, sqlDatabase); ProjectQueries projectQueries = new ProjectQueries(ctx, sqlDatabase); GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId); AclQueries aclQueries = new AclQueries(ctx, sqlDatabase); if (await aclQueries.VerifyGrantLevelByUserId(112, await aclQueries.GetAclIdBySchoolId(groupData.ParentZoneId), userId, Operator.SuperiorOrEqual) == false) { Result result = new Result(Status.Unauthorized, "Vous n'etes pas autorisé à utiliser cette fonctionnalité !"); return(this.CreateResult(result)); } List <ProjectInfosJuryData> projectInfosJuries = await projectQueries.getAllProjectsGrade(groupData.ZoneId); List <ProjectForumResultData> allProjectsForumResult = GetProjectsOfForum(projectInfosJuries); byte[] excelToArray = await excel.CreateExcel(allProjectsForumResult, projectQueries); return(File(excelToArray, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")); } }
public void TestCreateGetProjectsByPersonIdQuery_NoProjects() { var defaultSorter = new ExpressionSorter <ParticipantTimelineDTO>(x => x.Name, SortDirection.Ascending); var queryOperator = new QueryableOperator <ParticipantTimelineDTO>(0, 10, defaultSorter); var projects = ProjectQueries.CreateGetProjectsByPersonIdQuery(context, 1, queryOperator); Assert.AreEqual(0, projects.Count()); }
public void TestCreateGetProjectsByPersonIdQuery_CheckRelationships() { var person = new Person { PersonId = 1 }; var org = new Organization { OrganizationId = 1 }; var program = new Program { ProgramId = 1, Owner = org, OwnerId = org.OrganizationId }; var project = new Project { ProjectId = 1, ProgramId = program.ProgramId, ParentProgram = program }; var participant = new Participant { ParticipantId = 1, Person = person, PersonId = person.PersonId, Project = project, ProjectId = project.ProjectId }; context.Participants.Add(participant); var defaultSorter = new ExpressionSorter <ParticipantTimelineDTO>(x => x.Name, SortDirection.Ascending); var queryOperator = new QueryableOperator <ParticipantTimelineDTO>(0, 10, defaultSorter); var projects = ProjectQueries.CreateGetProjectsByPersonIdQuery(context, person.PersonId, queryOperator); Assert.AreEqual(1, projects.Count()); var projectResult = projects.FirstOrDefault(); Assert.AreEqual(project.ProjectId, projectResult.ProjectId); Assert.AreEqual(program.ProgramId, projectResult.ProgramId); Assert.AreEqual(org.OrganizationId, projectResult.OfficeId); }
public async Task <IActionResult> GetAllTypeProjectsOfASchool(int idSchool, char type) { SqlDefaultDatabase db = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>(); int userId = _authenticationInfo.ActualUser.UserId; using (var ctx = new SqlStandardCallContext()) { ProjectQueries projectQueries = new ProjectQueries(ctx, db); TimedPeriodQueries timedPeriodQueries = new TimedPeriodQueries(ctx, db); TimedUserQueries timedUserQueries = new TimedUserQueries(ctx, db); UserQueries userQueries = new UserQueries(ctx, db); GroupQueries groupQueries = new GroupQueries(ctx, db); PeriodData periodData = await timedPeriodQueries.GetLastPeriodBySchool(idSchool); //Implementer check date period TimedUserData timedUserData = await timedUserQueries.GetTimedUser(userId, periodData.ChildId); if (timedUserData == null) { timedUserData = new TimedUserData { TimedUserId = 0 }; } IEnumerable <AllProjectInfoData> projectData = await projectQueries.GetAllTypeProjectSpecificToSchoolWithTimedUserNote(periodData.ChildId, type, timedUserData.TimedUserId); for (var i = 0; i < projectData.Count(); i++) { IEnumerable <UserByProjectData> userByProject = await userQueries.GetUserByProject(projectData.ElementAt( i ).ProjectStudentId); projectData.ElementAt(i).BegDate = userByProject.ElementAt(0).BegDate; projectData.ElementAt(i).EndDate = userByProject.ElementAt(0).EndDate; foreach (var e in userByProject) { IEnumerable <GroupData> groupDatas = await groupQueries.GetAllGroupByTimedUser(e.TimedUserId); projectData.ElementAt(i).FirstName.Add(e.FirstName); projectData.ElementAt(i).LastName.Add(e.LastName); projectData.ElementAt(i).TimedUserId.Add(e.TimedUserId); projectData.ElementAt(i).UserId.Add(e.UserId); } } return(Ok(projectData)); } }
public async Task <IActionResult> VerifyProjectFav(int idProject) { int userId = _authenticationInfo.ActualUser.UserId; var sqlDataBase = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>(); using (var ctx = new SqlStandardCallContext()) { ProjectQueries projectQueries = new ProjectQueries(ctx, sqlDataBase); bool exist = await projectQueries.IsProjectFav(idProject, userId); return(Ok(exist)); } }
public void Init() { var sIndex = new IndexState(); var qIndex = new IndexQueries(sIndex); var hIndex = new IndexEventhandlers(sIndex); GivenMembership = new MembershipEventhandlers(hIndex); var sProject = new ProjectState(); var qProject = new ProjectQueries(qIndex); var hProject = new ProjectEventhandlers(sProject, hIndex); WhenProject = new Project(qProject, hProject); GivenProject = WhenProject.Handle; ThenProject = new Mock<Contracts.Projects.IHandleEvents>(); WhenProject.Handle = ThenProject.Object; }
public async Task add_or_update_note() { var userTable = TestHelper.StObjMap.StObjs.Obtain <CustomUserTable>(); var school = TestHelper.StObjMap.StObjs.Obtain <SchoolTable>(); var timePeriod = TestHelper.StObjMap.StObjs.Obtain <TimePeriodTable>(); var sqlDatabase = TestHelper.StObjMap.StObjs.Obtain <SqlDefaultDatabase>(); var noteTable = TestHelper.StObjMap.StObjs.Obtain <TimedUserNoteProjectTable>(); var projectStudent = TestHelper.StObjMap.StObjs.Obtain <ProjectStudentTable>(); var userTimed = TestHelper.StObjMap.StObjs.Obtain <TimedUserTable>(); DateTime dateTime = DateTime.Now; DateTime dateTime2 = DateTime.Now.AddDays(1); double grade = 10.5F; using (var ctx = new SqlStandardCallContext()) { ProjectQueries timedUserQueries = new ProjectQueries(ctx, sqlDatabase); var idSchool = await school.CreateSchool(ctx, 1, Guid.NewGuid().ToString()); var userId = await userTable.CreateUserAsync(ctx, 1, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); var id = await timePeriod.CreateTimePeriodAsync(ctx, 1, dateTime, dateTime2, "S", idSchool); // 0 = Anon Create TimedUser TimedUserStruct result = await userTimed.CreateOrUpdateTimedUserAsync(ctx, 0, id, userId); var ProjectCreate = await projectStudent.CreateProjectStudent(ctx, 1, 2, "name", 1, "a;b;c", "aaa", "okok", "wwww", 1, "I"); await noteTable.AddOrUpdateNote(ctx, result.TimedUserId, ProjectCreate.ProjectStudentId, grade); Assert.That(await timedUserQueries.GetProjectGradeSpecificTimedUser(ProjectCreate.ProjectStudentId, result.TimedUserId) == grade); Assert.That(await timedUserQueries.GetProjectGradeSpecificTimedUser(ProjectCreate.ProjectStudentId, result.TimedUserId) == grade); //Assert.That( await timedUserQueries.GetProjectGradeSpecJury( ProjectCreate.ProjectStudentId, result.TimedUserId ) == grade ); grade = 15; await noteTable.AddOrUpdateNote(ctx, result.TimedUserId, ProjectCreate.ProjectStudentId, grade); Assert.That(await timedUserQueries.GetProjectGradeSpecificTimedUser(ProjectCreate.ProjectStudentId, result.TimedUserId) == grade); // Assert.That( await timedUserQueries.GetProjectGradeSpecificTimedUser( ProjectCreate.ProjectStudentId, result.TimedUserId ) == grade ); // Assert.That( await timedUserQueries.GetProjectGradeSpecJury( ProjectCreate.ProjectStudentId, result.TimedUserId ) == grade ); } }
public void TestCreateGetProjectsByPersonIdQuery_CheckProperties() { var person = new Person { PersonId = 1 }; var project = new Project { ProjectId = 1, Name = "name", StartDate = new DateTime(2013, 5, 1, 06, 32, 00), EndDate = new DateTime(2017, 5, 1, 06, 32, 00), Description = "description" }; var participant = new Participant { ParticipantId = 1, Person = person, PersonId = person.PersonId, Project = project, ProjectId = project.ProjectId }; context.Participants.Add(participant); var defaultSorter = new ExpressionSorter <ParticipantTimelineDTO>(x => x.Name, SortDirection.Ascending); var queryOperator = new QueryableOperator <ParticipantTimelineDTO>(0, 10, defaultSorter); var projects = ProjectQueries.CreateGetProjectsByPersonIdQuery(context, person.PersonId, queryOperator); Assert.AreEqual(1, projects.Count()); var projectResult = projects.FirstOrDefault(); Assert.AreEqual(project.ProjectId, projectResult.ProjectId); Assert.AreEqual(participant.ParticipantId, projectResult.ParticipantId); Assert.AreEqual(project.Name, projectResult.Name); Assert.AreEqual(project.StartDate, projectResult.StartDate); Assert.AreEqual(project.EndDate, projectResult.EndDate); Assert.AreEqual(project.Description, projectResult.Description); Assert.IsNull(projectResult.OfficeSymbol); Assert.IsNull(projectResult.Status); }
public async Task add_url_to_a_project() { var urlTable = TestHelper.StObjMap.StObjs.Obtain <ProjectUrlTable>(); var projectStudent = TestHelper.StObjMap.StObjs.Obtain <ProjectStudentTable>(); var sqlDatabase = TestHelper.StObjMap.StObjs.Obtain <SqlDefaultDatabase>(); using (var ctx = new SqlStandardCallContext()) { ProjectQueries projectQueries = new ProjectQueries(ctx, sqlDatabase); var ProjectCreate = await projectStudent.CreateProjectStudent(ctx, 1, 2, "name", 1, "a;b;c", "aaa", "okok", "wwww", 1, "I"); var ProjectUrlCreate = await urlTable.CreateOrUpdateProjectUrl(ctx, ProjectCreate.ProjectStudentId, "www.aaa.fr", "Github"); ProjectUrlData urlData = await projectQueries.GetUrlByProject(ProjectCreate.ProjectStudentId); Assert.That(urlData.Url == "www.aaa.fr"); } }
public async Task <IEnumerable <AllProjectInfoData> > GetAllProjects() { SqlDefaultDatabase db = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>(); int userId = _authenticationInfo.ActualUser.UserId; using (var ctx = new SqlStandardCallContext()) { ProjectQueries projectQueries = new ProjectQueries(ctx, db); UserQueries userQueries = new UserQueries(ctx, db); GroupQueries groupQueries = new GroupQueries(ctx, db); IEnumerable <AllProjectInfoData> projectData = await projectQueries.GetAllProject(userId); for (var i = 0; i < projectData.Count(); i++) { IEnumerable <UserByProjectData> userByProject = await userQueries.GetUserByProject(projectData.ElementAt( i ).ProjectStudentId); projectData.ElementAt(i).BegDate = userByProject.ElementAt(0).BegDate; projectData.ElementAt(i).EndDate = userByProject.ElementAt(0).EndDate; List <string> listGroups = await projectQueries.GetGroupsOfProject(projectData.ElementAt(i).ProjectStudentId); List <string> semester = listGroups.FindAll(x => x.StartsWith("S0")); projectData.ElementAt(i).Semester = semester[0]; List <string> sector = listGroups.FindAll(x => x.StartsWith("IL") || x.StartsWith("SR")); if (sector.Count() > 0) { projectData.ElementAt(i).Sector = sector[0]; } GroupData data = await groupQueries.GetIdSchoolByPeriodId(projectData.ElementAt( i ).ZoneId); projectData.ElementAt(i).SchoolId = data.ParentZoneId; foreach (var e in userByProject) { //IEnumerable<GroupData> groupDatas = await groupQueries.GetAllGroupByTimedUser( e.TimedUserId ); projectData.ElementAt(i).FirstName.Add(e.FirstName); projectData.ElementAt(i).LastName.Add(e.LastName); projectData.ElementAt(i).TimedUserId.Add(e.TimedUserId); projectData.ElementAt(i).UserId.Add(e.UserId); } } return(projectData); } }
public void TestCreateGetProjectsByPersonIdQuery_CheckStatus() { var person = new Person { PersonId = 1 }; var status = new ProjectStatus { ProjectStatusId = 1, Status = "status" }; var project = new Project { ProjectId = 1, Status = status, ProjectStatusId = status.ProjectStatusId }; var participant = new Participant { ParticipantId = 1, Person = person, PersonId = person.PersonId, Project = project, ProjectId = project.ProjectId }; context.Participants.Add(participant); var defaultSorter = new ExpressionSorter <ParticipantTimelineDTO>(x => x.Name, SortDirection.Ascending); var queryOperator = new QueryableOperator <ParticipantTimelineDTO>(0, 10, defaultSorter); var projects = ProjectQueries.CreateGetProjectsByPersonIdQuery(context, person.PersonId, queryOperator); Assert.AreEqual(1, projects.Count()); var projectResult = projects.FirstOrDefault(); Assert.AreEqual(status.Status, projectResult.Status); }
public async Task a_user_fav_a_project() { var projectStudent = TestHelper.StObjMap.StObjs.Obtain <ProjectStudentTable>(); var userTable = TestHelper.StObjMap.StObjs.Obtain <UserTable>(); var userFavTable = TestHelper.StObjMap.StObjs.Obtain <UserFavProjectTable>(); var sqlDatabase = TestHelper.StObjMap.StObjs.Obtain <SqlDefaultDatabase>(); using (var ctx = new SqlStandardCallContext()) { ProjectQueries projectQueries = new ProjectQueries(ctx, sqlDatabase); var ProjectCreate = await projectStudent.CreateProjectStudent(ctx, 1, 2, "name", 1, "a;b;c", "aaa", "okok", "wwww", 1, "I"); var userCreate = await userTable.CreateUserAsync(ctx, 1, Guid.NewGuid().ToString()); await userFavTable.FavOrUnfavProject(ctx, userCreate, ProjectCreate.ProjectStudentId); //UserFavProjectData userFavProjectData = await projectQueries.GetSPecificFavOfUser( userCreate, ProjectCreate.ProjectStudentId ); // Assert.That( userFavProjectData != null ); } }
public async Task <IActionResult> GetAllPublicNote() { SqlDefaultDatabase db = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>(); int userId = _authenticationInfo.ActualUser.UserId; using (var ctx = new SqlStandardCallContext()) { ProjectQueries projectQueries = new ProjectQueries(ctx, db); TimedPeriodQueries timedPeriodQueries = new TimedPeriodQueries(ctx, db); TimedUserQueries timedUserQueries = new TimedUserQueries(ctx, db); UserQueries userQueries = new UserQueries(ctx, db); GroupQueries groupQueries = new GroupQueries(ctx, db); GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId); List <ProjectForumResultData> projects = await projectQueries.GetAllPublicsNoteByTimedPeriodId(groupData.ZoneId); return(Ok(projects)); } }
public async Task <IActionResult> GetProjects() { int userId = _authenticationInfo.ActualUser.UserId; var sqlDataBase = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>(); using (var ctx = new SqlStandardCallContext()) { ProjectQueries projectQueries = new ProjectQueries(ctx, sqlDataBase); List <ProjectData> userProjects = await projectQueries.GetProjectsUser(userId); //ProjectData test = userProjects[0]; //userProjects.Add( test ); //userProjects.Add( test ); //userProjects.Add( test ); return(Ok(userProjects)); } }
public async Task <IEnumerable <AllProjectInfoData> > GetProjectsEvaluate(int idSchool) { SqlDefaultDatabase db = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>(); int userId = _authenticationInfo.ActualUser.UserId; using (var ctx = new SqlStandardCallContext()) { ProjectQueries projectQueries = new ProjectQueries(ctx, db); TimedPeriodQueries timedPeriodQueries = new TimedPeriodQueries(ctx, db); TimedUserQueries timedUserQueries = new TimedUserQueries(ctx, db); UserQueries userQueries = new UserQueries(ctx, db); GroupQueries groupQueries = new GroupQueries(ctx, db); PeriodData periodData = await timedPeriodQueries.GetLastPeriodBySchool(idSchool); //Implementer check date period IEnumerable <AllProjectInfoData> projectData = await projectQueries.GetAllProjectTimedByJuryId(userId, periodData.ChildId); return(projectData); } }
public ProjectService( ProjectQueries queries ) { _queries = queries; }
// may we should rewrite the sql query public async Task <object> GetProjectSheet(int idx) { SqlDefaultDatabase db = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>(); int userId = _authenticationInfo.ActualUser.UserId; ProjectData pd; List <UserData> lst_usr_data; List <string> lst_grp; using (SqlStandardCallContext ctx = new SqlStandardCallContext()) { ProjectQueries projectQueries = new ProjectQueries(ctx, db); pd = await projectQueries.GetDetailProject(idx); lst_usr_data = await projectQueries.GetAllUsersOfProject(idx); lst_grp = await projectQueries.GetGroupsOfProject(idx); } string name = pd.Name; // semesters of the project List <int> semesters = new List <int>(); foreach (string elem in lst_grp) { if (elem[0] == 'S' && (elem[1] == '0' || elem[1] == '1')) { semesters.Add(int.Parse(elem.Substring(1, elem.Length - 1))); } } semesters.Sort(); string semester = String.Join(", ", semesters); // sector of the project string sector = lst_grp.Contains("SR") && lst_grp.Contains("IL") ? "IL - SR" : lst_grp.Contains("SR") ? "SR" : lst_grp.Contains("IL") ? "IL" : ""; // download and encode the image in base64 string logo = Convert.ToBase64String(new WebClient().DownloadData(pd.Logo)); string slogan = pd.Slogan; string pitch = pd.Pitch; // check who is the leader string[] members = new string[lst_usr_data.Count - 1]; string leader = ""; foreach (UserData usr in lst_usr_data) { if (usr.UserId == pd.LeaderId) { leader = usr.FirstName + " " + usr.LastName; } else { members[Array.IndexOf(members, null)] = usr.FirstName + " " + usr.LastName; } } (string, string[])team = (leader, members); // check the type for the field techno of background field and return the project if (pd.Type == "I") { string[] place = new string[2]; place[0] = pd.ClassRoom; place[1] = pd.ForumNumber.ToString(); string[] technos = pd.Technologies.ToArray(); return(new { project = new ProjectPiSheet(place, name, semester, sector, logo, slogan, pitch, team, technos), type = "I" }); } else if (pd.Type == "H") { // download and encode the background in base64 string background = Convert.ToBase64String(new WebClient().DownloadData(pd.Background)); return(new { project = new ProjectPfhSheet(name, semester, sector, logo, slogan, pitch, team, background), type = "H" }); } else { return(new { project = new ProjectSheet(name, semester, sector, logo, slogan, pitch, team, "None"), type = "None" }); } }
public async Task <IActionResult> GetAllSheet(int schoolId, char projectType, int semester) { SqlDefaultDatabase db = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>(); using (SqlStandardCallContext ctx = new SqlStandardCallContext()) { ProjectQueries projectQueries = new ProjectQueries(ctx, db); TimedPeriodQueries timedPeriodQueries = new TimedPeriodQueries(ctx, db); PeriodData School = await timedPeriodQueries.GetLastPeriodBySchool(schoolId); IEnumerable <AllProjectInfoData> listProject; if (semester > 0) { if (projectType == 'I' || projectType == 'H') { listProject = await projectQueries.GetAllTypeSchoolProject(School.ChildId, projectType, semester); } else { listProject = await projectQueries.GetAllTypeSchoolProject(School.ChildId, semester); } } else { if (projectType == 'I' || projectType == 'H') { listProject = await projectQueries.GetAllTypeSchoolProject(School.ChildId, projectType); } else { listProject = await projectQueries.GetAllTypeSchoolProject(School.ChildId); } } if (projectType == 'I') { List <ProjectPiSheet> projectsSheet = new List <ProjectPiSheet>(); foreach (var item in listProject) { string[] place = new string[2]; place[0] = item.ClassRoom; place[1] = item.ForumNumber.ToString(); string[] members = new string[item.UsersData.Count - 1]; string leader = ""; foreach (UserData usr in item.UsersData) { if (usr.UserId == item.LeaderId) { leader = usr.FirstName + " " + usr.LastName; } else { members[Array.IndexOf(members, null)] = usr.FirstName + " " + usr.LastName; } } (string, string[])team = (leader, members); ProjectPiSheet projectPiSheet = new ProjectPiSheet(place, item.GroupName, item.Semester, item.Sector, item.Logo, item.Slogan, item.Pitch, team, item.Technologies.ToArray()); projectsSheet.Add(projectPiSheet); } return(Ok(projectsSheet)); } else if (projectType == 'H') { List <ProjectPfhSheet> projectsSheet = new List <ProjectPfhSheet>(); foreach (var item in listProject) { string[] members = new string[item.UsersData.Count - 1]; string leader = ""; foreach (UserData usr in item.UsersData) { if (usr.UserId == item.LeaderId) { leader = usr.FirstName + " " + usr.LastName; } else { members[Array.IndexOf(members, null)] = usr.FirstName + " " + usr.LastName; } } (string, string[])team = (leader, members); string background = Convert.ToBase64String(new WebClient().DownloadData("https://drive.google.com/uc?id=143SNqM-rxFmDSrA7A2Wa29eu-gqhtdOn")); ProjectPfhSheet projectPfhSheet = new ProjectPfhSheet(item.GroupName, item.Semester, "", item.Logo, item.Slogan, item.Pitch, team, background); projectsSheet.Add(projectPfhSheet); } return(Ok(projectsSheet)); } else { List <ProjectSheet> projectsSheet = new List <ProjectSheet>(); foreach (var item in listProject) { string[] members = new string[item.UsersData.Count - 1]; string leader = ""; foreach (UserData usr in item.UsersData) { if (usr.UserId == item.LeaderId) { leader = usr.FirstName + " " + usr.LastName; } else { members[Array.IndexOf(members, null)] = usr.FirstName + " " + usr.LastName; } } (string, string[])team = (leader, members); if (item.Type == "H") { string background = Convert.ToBase64String(new WebClient().DownloadData("https://drive.google.com/uc?id=143SNqM-rxFmDSrA7A2Wa29eu-gqhtdOn")); ProjectPfhSheet projectPfhSheet = new ProjectPfhSheet(item.GroupName, item.Semester, "", item.Logo, item.Slogan, item.Pitch, team, background); projectsSheet.Add(projectPfhSheet); } else { string[] place = new string[2]; place[0] = item.ClassRoom; place[1] = item.ForumNumber.ToString(); ProjectPiSheet projectPiSheet = new ProjectPiSheet(place, item.GroupName, item.Semester, item.Sector, item.Logo, item.Slogan, item.Pitch, team, item.Technologies.ToArray()); projectsSheet.Add(projectPiSheet); } } return(Ok(projectsSheet)); } } }
/// <summary> /// The query to get project dtos. /// </summary> /// <returns>The query to get project dtos.</returns> public override IQueryable <ProjectDTO> CreateGetDocumentsQuery() { return(ProjectQueries.CreateGetProjectDTOQuery(this.Context).OrderBy(x => x.Id)); }
public async Task <IActionResult> NoteProject([FromBody] NoteProjectViewModel model) { int userId = _authenticationInfo.ActualUser.UserId; TimedUserNoteProjectTable timedUserNoteProjectTable = _stObjMap.StObjs.Obtain <TimedUserNoteProjectTable>(); TimedUserTable timedUserTable = _stObjMap.StObjs.Obtain <TimedUserTable>(); EvaluatesTable evaluatesTable = _stObjMap.StObjs.Obtain <EvaluatesTable>(); SqlDefaultDatabase db = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>(); PeriodServices periodServices = new PeriodServices(); using (var ctx = new SqlStandardCallContext()) { ProjectQueries projectQueries = new ProjectQueries(ctx, db); TimedPeriodQueries timedPeriodQueries = new TimedPeriodQueries(ctx, db); UserQueries userQueries = new UserQueries(ctx, db); TimedUserQueries timedUserQueries = new TimedUserQueries(ctx, db); AclQueries aclQueries = new AclQueries(ctx, db); GroupQueries groupQueries = new GroupQueries(ctx, db); //Case Change Grade by Administration ==================================================================================================================== if (model.User == ViewModels.TypeTimedUser.StaffMember) { if (!await periodServices.CheckInPeriod(_stObjMap, _authenticationInfo)) { Result result = new Result(Status.Unauthorized, "A la date d'aujourd'hui votre etablissement n'est dans une aucune periode"); return(this.CreateResult(result)); } GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId); if (!await aclQueries.VerifyGrantLevelByUserId(112, await aclQueries.GetAclIdBySchoolId(groupData.ParentZoneId), userId, Operator.SuperiorOrEqual)) { Result result = new Result(Status.Unauthorized, "Vous n'etes pas autorisé à utiliser cette fonctionnalité !"); return(this.CreateResult(result)); } await evaluatesTable.EvaluateOrUpdateGradeProject(ctx, model.JuryId, model.ProjectId, model.Grade); return(Ok()); } //========================================================================================================================================================= PeriodData periodData = await timedPeriodQueries.GetLastPeriodBySchool(model.SchoolId); TimedUserData timedUserData = await timedUserQueries.GetTimedUser(userId, periodData.ChildId); if (timedUserData == null) { TimedUserStruct timedUser = await timedUserTable.CreateOrUpdateTimedUserAsyncWithType(ctx, Data.TypeTimedUser.Anon, periodData.ChildId, userId); timedUserData = new TimedUserData { TimedUserId = timedUser.TimedUserId }; await timedUserNoteProjectTable.AddOrUpdateNote(ctx, timedUserData.TimedUserId, model.ProjectId, model.Grade); return(Ok()); } if (model.User == ViewModels.TypeTimedUser.Jury) { await evaluatesTable.EvaluateOrUpdateGradeProject(ctx, model.JuryId, model.ProjectId, model.Grade); } else { await timedUserNoteProjectTable.AddOrUpdateNote(ctx, timedUserData.TimedUserId, model.ProjectId, model.Grade); } return(Ok()); } }
public Project GetById(Guid id) { return(_context.Project.AsNoTracking().FirstOrDefault(ProjectQueries.GetById(id))); }
internal async Task AssignProjectToJury(IStObjMap stObjMap, IAuthenticationInfo authenticationInfo, List <JuryInfos> juryInfos, string type) { using (var ctx = new SqlStandardCallContext()) { var sqlDatabase = stObjMap.StObjs.Obtain <SqlDefaultDatabase>(); var groupTable = stObjMap.StObjs.Obtain <CustomGroupTable>(); var userTimedTable = stObjMap.StObjs.Obtain <TimedUserTable>(); EvaluatesTable evaluatesTable = stObjMap.StObjs.Obtain <EvaluatesTable>(); int userId = authenticationInfo.ActualUser.UserId; GroupQueries groupQueries = new GroupQueries(ctx, sqlDatabase); GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId); string userName = Guid.NewGuid().ToString(); UserQueries userQueries = new UserQueries(ctx, sqlDatabase); TimedUserQueries timedUserQueries = new TimedUserQueries(ctx, sqlDatabase); ProjectQueries projectQueries = new ProjectQueries(ctx, sqlDatabase); TimedPeriodQueries timedPeriodQueries = new TimedPeriodQueries(ctx, sqlDatabase); ForumQueries forumQueries = new ForumQueries(ctx, sqlDatabase); //get the Begdate of the periode DateTime begDate = await timedPeriodQueries.GetBegDateOfPeriod(groupData.ZoneId); foreach (JuryInfos juryInfo in juryInfos) { if (juryInfo.Mail == "*****@*****.**") { Console.WriteLine("ok"); } int enterpriseId = 0; string groupName = "Jury " + juryInfo.Jury + "-" + begDate.Year + "/" + begDate.Month; int timedUserType = 0; //Check if the jury group exists or not at a moment int groupId = await groupQueries.GetSpecificIdGroupByZoneIdAndGroupName(groupData.ZoneId, groupName); if (groupId == 0) { groupId = await groupTable.CreateGroupAsync(ctx, userId, groupData.ZoneId); await groupTable.Naming.GroupRenameAsync(ctx, userId, groupId, groupName); } //Check if the enterprise group exists or not at a moment enterpriseId = await groupQueries.GetSpecificIdGroupByZoneIdAndGroupName(groupData.ZoneId, juryInfo.Entreprise); if (enterpriseId == 0) { enterpriseId = await groupTable.CreateGroupAsync(ctx, userId, groupData.ZoneId); await groupTable.Naming.GroupRenameAsync(ctx, userId, enterpriseId, juryInfo.Entreprise); } //Check if the user exists int idJury = await CheckIfUserExists(stObjMap, authenticationInfo, juryInfo.Mail, userName, juryInfo.Prenom, juryInfo.Nom); await groupTable.AddUserAsync(ctx, userId, groupId, idJury, true); await groupTable.AddUserAsync(ctx, userId, enterpriseId, idJury, true); //get the timed user type timedUserType = GetTimedUserType(type); //check if the timed user exists TimedUserData timedUserData = await userQueries.CheckIfTimedUserExists(idJury, groupData.ZoneId); if (timedUserData == null) { await userTimedTable.CreateOrUpdateTimedUserAsync(ctx, timedUserType, groupData.ZoneId, idJury); } else { bool isJury = await timedUserQueries.IsJury(timedUserData.TimedUserId); if (!isJury) { await userTimedTable.CreateOrUpdateTimedUserAsync(ctx, timedUserType, groupData.ZoneId, idJury); } } //get the project id by forumnumber ProjectData projectId; string groupName1 = "Vous êtes libre"; string groupName2 = "Vous êtes libre"; string groupName3 = "Vous êtes libre"; string groupName4 = "Vous êtes libre"; TimeSpan timeSpan1 = new TimeSpan(13, 30, 0); TimeSpan timeSpan2 = new TimeSpan(14, 15, 0); TimeSpan timeSpan3 = new TimeSpan(15, 00, 0); TimeSpan timeSpan4 = new TimeSpan(15, 45, 0); if (juryInfo.Groupe1 != 0) { projectId = await projectQueries.GetProjectIdByForumNumberAndPeriod(juryInfo.Groupe1, groupData.ZoneId); begDate = begDate.Date + timeSpan1; if (await forumQueries.IsProjectJudgedByJury(projectId.ProjectStudentId, groupId) == 0) { await evaluatesTable.EvaluateOrUpdateGradeProject(ctx, groupId, projectId.ProjectStudentId, -1, begDate); } groupName1 = projectId.GroupName; } if (juryInfo.Groupe2 != 0) { projectId = await projectQueries.GetProjectIdByForumNumberAndPeriod(juryInfo.Groupe2, groupData.ZoneId); begDate = begDate.Date + timeSpan2; if (await forumQueries.IsProjectJudgedByJury(projectId.ProjectStudentId, groupId) == 0) { await evaluatesTable.EvaluateOrUpdateGradeProject(ctx, groupId, projectId.ProjectStudentId, -1, begDate); } groupName2 = projectId.GroupName; } if (juryInfo.Groupe3 != 0) { projectId = await projectQueries.GetProjectIdByForumNumberAndPeriod(juryInfo.Groupe3, groupData.ZoneId); begDate = begDate.Date + timeSpan3; if (await forumQueries.IsProjectJudgedByJury(projectId.ProjectStudentId, groupId) == 0) { await evaluatesTable.EvaluateOrUpdateGradeProject(ctx, groupId, projectId.ProjectStudentId, -1, begDate); } groupName3 = projectId.GroupName; } if (juryInfo.Groupe4 != 0) { projectId = await projectQueries.GetProjectIdByForumNumberAndPeriod(juryInfo.Groupe4, groupData.ZoneId); begDate = begDate.Date + timeSpan4; if (await forumQueries.IsProjectJudgedByJury(projectId.ProjectStudentId, groupId) == 0) { await evaluatesTable.EvaluateOrUpdateGradeProject(ctx, groupId, projectId.ProjectStudentId, -1, begDate); } groupName4 = projectId.GroupName; } IEnumerable <ForumData> infoMail = await forumQueries.ForumInfoByJury(groupName); int nbProject = infoMail.Count(); string subject = "Votre participation au Forum PI D'IN'TECH"; string mailContent = @" <table align = 'center' border='0' cellpadding='0' cellspacing='0' height='100%' width='100%' id='bodyTable'> </tr> <tr> <td valign = 'top' id='templateBody'><table border = '0' cellpadding='0' cellspacing='0' width='100%' class='mcnTextBlock' style='min-width:100%;'> <tbody class='mcnTextBlockOuter'> <tr> <td valign = 'top' class='mcnTextBlockInner' style='padding-top:9px;'> <!--[if mso]> <table align = 'left' border='0' cellspacing='0' cellpadding='0' width='100%' style='width:100%;'> <tr> <![endif]--> <!--[if mso]> <td valign = 'top' width='600' style='width:600px;'> <![endif]--> <table align = 'left' border='0' cellpadding='0' cellspacing='0' style='max-width:100%; min-width:100%;' width='100%' class='mcnTextContentContainer'> <tbody><tr> <td valign = 'top' class='mcnTextContent' style='padding-top:0; padding-right:18px; padding-bottom:9px; padding-left:18px;'> <h1>Bonjour " + juryInfo.Prenom + " " + juryInfo.Nom + @"</h1> <p>Vous participez au forum des projets informatique de l'école IN'TECH le " + begDate.Day + "/0" + begDate.Month + "/" + begDate.Year + @".</p> <p>Vous appartenez au jury '" + groupName + @"'.<br> Au cours de cet évènement vous aurez l'occasion de juger les projets suivants: </p> <ul> <li>" + groupName1 + " à " + timeSpan1 + @"</li> <li>" + groupName2 + " à " + timeSpan2 + @"</li> <li>" + groupName3 + " à " + timeSpan3 + @"</li> <li>" + groupName4 + " à " + timeSpan4 + @"</li> </ul> Nous vous remercions de l’intérêt que vous portez à nos évènements.<br> Bonne continuation. </td> </tr> </tbody></table> <!--[if mso]> </td> <![endif]--> <!--[if mso]> </tr> </table> <![endif]--> </td> </tr> </tbody> </table></td> </tr> <tr> <td valign = 'top' id= 'templateFooter' > <td align = 'center' style='padding-left:9px;padding-right:9px;'> <table border = '0' cellpadding='0' cellspacing='0' width='100%' style='min-width:100%;' class='mcnFollowContent'> <tbody><tr> <td align = 'center' valign='top' style='padding-top:9px; padding-right:9px; padding-left:9px;'> <table align = 'center' border='0' cellpadding='0' cellspacing='0'> <tbody><tr> <td align = 'center' valign='top'> <!--[if mso]> <table align = 'center' border='0' cellspacing='0' cellpadding='0'> <tr> <![endif]--> </td> </tr> </tbody></table> </td> </tr> </tbody></table> </td> </tr> </tbody></table> </td> </tr> </tbody> </table> <tbody class='mcnDividerBlockOuter'> <tr> <td class='mcnDividerBlockInner' style='min-width: 100%; padding: 10px 18px 25px;'> <table class='mcnDividerContent' border='0' cellpadding='0' cellspacing='0' width='100%' style='min-width: 100%;border-top: 2px solid #EEEEEE;'> <tbody><tr> <td> <span></span> </td> </tr> </tbody></table> <!-- <td class='mcnDividerBlockInner' style='padding: 18px;'> <hr class='mcnDividerContent' style='border-bottom-color:none; border-left-color:none; border-right-color:none; border-bottom-width:0; border-left-width:0; border-right-width:0; margin-top:0; margin-right:0; margin-bottom:0; margin-left:0;' /> --> </td> </tr> </tbody> </table> <tbody class='mcnTextBlockOuter'> <tr> <td valign = 'top' class='mcnTextBlockInner' style='padding-top:9px;'> <!--[if mso]> <td valign = 'top' width='600' style='width:600px;'> <![endif]--> <table align = 'left' border='0' cellpadding='0' cellspacing='0' style='max-width:100%; min-width:100%;' width='100%' class='mcnTextContentContainer'> <tbody><tr> <td valign = 'top' class='mcnTextContent' style='padding-top:0; padding-right:18px; padding-bottom:9px; padding-left:18px;'> <br> <br> <strong>Notre adresse:</strong><br> 74 bis Avenue Maurice Thorez, 94200 Ivry-sur-Seine<br> Metro 7: Pierre et Marie Curie<br> <br> IN'TECH Paris </td> </tr> </tbody></table> <!--[if mso]> </td> <![endif]--> <!--[if mso]> </tr> </table> <![endif]--> </td> </tr> </tbody> </table></td> </tr> </table> <!--[if (gte mso 9)|(IE)]> </td> </tr> </table> <![endif]--> <!-- // END TEMPLATE --> </td> </tr> </table> </center> </body> </html>"; await _emailSender.SendMessage(juryInfo.Mail, subject, mailContent); } } }