public async Task <ActionResult> GetFilteredGroups([FromQuery] string name, [FromQuery] string field, [FromQuery] bool orderByName, [FromQuery] bool descending, [FromQuery] int from, [FromQuery] int to, [FromQuery] int user) { string userFilter = "not (s)-[:MEMBER|:OWNER]->(g) and ID(s) = " + user; string where1 = (string.IsNullOrEmpty(name) ? "" : ("g.Name =~\"(?i).*" + name + ".*\"")); string where2 = (string.IsNullOrEmpty(field) ? "" : ("g.Field =~ \"(?i).*" + field + ".*\"")); string where = ""; if (!string.IsNullOrEmpty(where1) && !string.IsNullOrEmpty(where2)) { where += where1 + " AND " + where2; } else if (!string.IsNullOrEmpty(where1)) { where += where1; } else if (!string.IsNullOrEmpty(where2)) { where += where2; } string order = orderByName ? "g.Name" : "ID(g)"; IEnumerable <GroupDTO> groups; groups = await _repository.GetGroupsPage(where, userFilter, order, descending, from, to); foreach (GroupDTO g in groups) { g.Group.GroupPicturePath = FileManagerService.LoadImageFromFile(g.Group.GroupPicturePath); } return(Ok(new JsonResult(groups))); }
public async Task <ActionResult> GetGroupStatistics(int groupId) { GroupStatisticsDTO result = await _repository.GetGroupStatistics(groupId); result.Group.GroupPicturePath = FileManagerService.LoadImageFromFile(result.Group.GroupPicturePath); return(Ok(result)); }
public async Task <ActionResult> getGroupImage(int groupId) { string path = await _repository.GetGroupImage(groupId); path = FileManagerService.LoadImageFromFile(path); return(Ok(new { image = path })); }
public async Task <IActionResult> CreateComment(int postId, int studentId, Comment newComment) { CommentDTO res = await _repository.CreateComment(postId, studentId, newComment); res.Student.Student.ProfilePicturePath = FileManagerService.LoadImageFromFile(res.Student.Student.ProfilePicturePath); return(Ok(res)); }
public async Task <ActionResult> GetGroupOwner(int groupId, int studentId) { var result = await _repository.GetGroupOwner(groupId, studentId); result.Student.ProfilePicturePath = FileManagerService.LoadImageFromFile(result.Student.ProfilePicturePath); return(Ok(result)); }
public async Task <ActionResult> GetSpecificStudent(int studentId, int requesterId) { StudentDTO student = await _repository.GetSpecificStudent(studentId, requesterId); student.Student.ProfilePicturePath = FileManagerService.LoadImageFromFile(student.Student.ProfilePicturePath); return(Ok(student)); }
public async Task <ActionResult> CreatePost(int groupId, int studentId, Post newPost) { PostDTO res = await _repository.CreatePost(groupId, studentId, newPost); res.Student.Student.ProfilePicturePath = FileManagerService.LoadImageFromFile(res.Student.Student.ProfilePicturePath); return(Ok(res)); }
public async Task <ActionResult> GetStudentGroups(int studentId) { IEnumerable <GroupDTO> result = await _repository.GetStudentGroups(studentId); foreach (GroupDTO res in result) { res.Group.GroupPicturePath = FileManagerService.LoadImageFromFile(res.Group.GroupPicturePath); } return(Ok(result)); }
public async Task <ActionResult> GetMyOwnerships(int studentId) { var result = await _repository.GetOwnerships(studentId); foreach (GroupDTO g in result) { g.Group.GroupPicturePath = FileManagerService.LoadImageFromFile(g.Group.GroupPicturePath); } return(Ok(result)); }
public async Task <ActionResult> GetAllComments(int postId) { IEnumerable <CommentDTO> result = await _repository.GetAllComments(postId); foreach (CommentDTO item in result) { item.Student.Student.ProfilePicturePath = FileManagerService.LoadImageFromFile(item.Student.Student.ProfilePicturePath); } return(Ok(result)); }
public async Task <ActionResult> GetAllPosts(int groupId) { IEnumerable <PostDTO> result = await _repository.GetAllPosts(groupId); foreach (PostDTO r in result) { r.Student.Student.ProfilePicturePath = FileManagerService.LoadImageFromFile(r.Student.Student.ProfilePicturePath); } return(Ok(result)); }
public async Task <ActionResult> GetGroupMembers(int groupId, int studentId) { var result = await _repository.GetGroupMembers(groupId, studentId); foreach (StudentDTO s in result) { s.Student.ProfilePicturePath = FileManagerService.LoadImageFromFile(s.Student.ProfilePicturePath); } return(Ok(result)); }
public async Task <ActionResult> GetFilteredStudents([FromQuery] string firstName, [FromQuery] string lastName, [FromQuery] bool orderByName, [FromQuery] bool descending, int from, int to, int user) { string userFilter = "(not ID(s1)=" + user + ") and ID(s2)=" + user; string whereFirstName = string.IsNullOrEmpty(firstName) ? "" : ("s1.FirstName=~\"(?i).*" + firstName + ".*\""); string whereLastName = string.IsNullOrEmpty(lastName) ? "" : ("s1.LastName=~\"(?i).*" + lastName + ".*\""); string where = ""; if (!string.IsNullOrEmpty(whereFirstName) && !string.IsNullOrEmpty(whereLastName)) { where += whereFirstName + " AND " + whereLastName; } else if (!string.IsNullOrEmpty(whereFirstName)) { where += whereFirstName; } else if (!string.IsNullOrEmpty(whereLastName)) { where += whereLastName; } string order = ""; if (!orderByName) { order += "ID(s1)"; if (descending) { order += " desc"; } } else { if (descending) { order += "s1.FirstName desc, s1.LastName desc"; } else { order += "s1.FirstName, s1.LastName"; } } IEnumerable <StudentDTO> students; students = await _repository.GetStudentsPage(where, userFilter, order, descending, from, to, user); foreach (StudentDTO s in students) { s.Student.ProfilePicturePath = FileManagerService.LoadImageFromFile(s.Student.ProfilePicturePath); } return(Ok(students)); }
public async Task <ActionResult> GetNews(string newsId, [FromQuery] int commentsCount) { var news = await _repository.GetNews(newsId, commentsCount); if (!string.IsNullOrEmpty(news.MainPicturePath)) { news.MainPicturePath = FileManagerService.LoadImageFromFile(news.MainPicturePath); } if (news.Paragraphs != null) { foreach (Paragraph p in news.Paragraphs) { if (!string.IsNullOrEmpty(p.PicturePath)) { p.PicturePath = FileManagerService.LoadImageFromFile(p.PicturePath); } } } return(Ok(news)); }
public NewsProfiles() { CreateMap <News, NewsInfoDTO>() .ForMember(dest => dest.Paragraphs, opt => opt.MapFrom( src => new List <Paragraph>() { new Paragraph { Text = src.Paragraphs[0].Text, SubTitle = src.Paragraphs[0].SubTitle, PicturePath = !string.IsNullOrEmpty(src.Paragraphs[0].PicturePath) ? FileManagerService.LoadImageFromFile("paragraphPicture0" + src.Id) : null } })) .ForMember(dest => dest.MainPicturePath, opt => opt.MapFrom( src => !string.IsNullOrEmpty(src.MainPicturePath) ? FileManagerService.LoadImageFromFile("mainPicture" + src.Id) : null)); }
public async Task <ActionResult> LogUserIn([FromBody] AccountLogInDTO userCredentials) { string savedPwd = await _repository.GetPassword(userCredentials.Email); if (savedPwd != null) { if (AuthentificationService.IsPasswordCorrect(savedPwd, userCredentials.Password)) { StudentDTO student = await _repository.StudentExists(userCredentials.Email); student.Student.ProfilePicturePath = FileManagerService.LoadImageFromFile(student.Student.ProfilePicturePath); string token = JwtManager.GenerateJWToken(student.Student, student.Id.ToString()); return(Ok(new JsonResult(token))); } else { return(Ok(new JsonResult("Wrong password"))); } } else { return(Ok(new JsonResult("Non-existent email"))); } }