public void TryToInviteTeacherToGroupWithApprovedTeacher_GetException() { //Arrange var publisher = new Mock <IEventPublisher>(); var groupFacade = new GroupFacade(_groupRepository, _userRepository, _sanctionRepository, new GroupSettings(1, 100, 0, 1000), publisher.Object); var accountFacade = new AccountFacade(_keysRepository, _userRepository, _emailSender.Object, userSettings); var userFacade = new UserFacade(_userRepository, _groupRepository, _eventRepository, _publisher.Object); var creatorId = accountFacade.RegUser("Creator", new Credentials("email1", "password"), false); var teacherId = accountFacade.RegUser("Teacher", new Credentials("email2", "password"), true); var anotherTeacherId = accountFacade.RegUser("Another teacher", new Credentials("email3", "password"), true); var createdGroupId = groupFacade.CreateGroup(creatorId, "Some group", new List <string> { "c#" }, "Very interesting", 1, 100, false, GroupType.Lecture); var createdGroup = groupFacade.GetGroup(createdGroupId, creatorId); groupFacade.ApproveTeacher(userFacade.GetUser(teacherId).Id, createdGroupId); //Act userFacade.Invite(creatorId, anotherTeacherId, createdGroupId, MemberRole.Teacher); }
public void TryToInviteUserWithTeacherFlag_IsItPossible() { //Arrange var publisher = new Mock <IEventPublisher>(); var groupFacade = new GroupFacade(_groupRepository, _userRepository, _sanctionRepository, new GroupSettings(1, 100, 0, 1000), publisher.Object); var accountFacade = new AccountFacade(_keysRepository, _userRepository, _emailSender.Object, userSettings); var userFacade = new UserFacade(_userRepository, _groupRepository, _eventRepository, _publisher.Object); var creatorId = accountFacade.RegUser("Creator", new Credentials("email1", "password"), false); var teacherId = accountFacade.RegUser("Teacher", new Credentials("email2", "password"), true); var createdGroupId = groupFacade.CreateGroup(creatorId, "Some group", new List <string> { "c#" }, "Very interesting", 1, 100, false, GroupType.Lecture); //Act userFacade.Invite(creatorId, teacherId, createdGroupId, MemberRole.Teacher); var invitations = userFacade.GetAllInvitationsForUser(teacherId).ToList(); //Assert Assert.AreEqual(createdGroupId, invitations[0].ToGroup); }
public Mutations(MarkFacade markFacade, UserFacade userFacade, GroupFacade groupFacade, GroupSubjectFacade groupSubjectFacade, NotificationFacade notificationFacade, NotificationStudentFacade notificationStudentFacade, SubjectFacade subjectFacade, UserGroupFacade userGroupFacade, UserMarkFacade userMarkFacade, UserRoleFacade userRoleFacade) { AddMarkMutations(markFacade); AddUserMutations(userFacade, userRoleFacade, userGroupFacade, groupFacade); AddGroupMutations(groupFacade); AddGroupSubjectMutations(groupSubjectFacade, userFacade); AddNotificationMutations(notificationFacade, groupFacade, notificationStudentFacade); AddNotificationStudentMutations(notificationStudentFacade); AddSubjectMutations(subjectFacade); AddUserGroupMutations(userGroupFacade); AddUserMarkMutations(userMarkFacade); AddUserRoleMutations(userRoleFacade); }
public void AcceptUserInvitation_GetAddedUserToGroup() { //Arrange var publisher = new Mock <IEventPublisher>(); var groupFacade = new GroupFacade(_groupRepository, _userRepository, _sanctionRepository, new GroupSettings(1, 100, 0, 1000), publisher.Object); var accountFacade = new AccountFacade(_keysRepository, _userRepository, _emailSender.Object, userSettings); var userFacade = new UserFacade(_userRepository, _groupRepository, _eventRepository, _publisher.Object); var creatorId = accountFacade.RegUser("Creator", new Credentials("email1", "password"), false); var invitedId = accountFacade.RegUser("Teacher", new Credentials("email2", "password"), true); var createdGroupId = groupFacade.CreateGroup(creatorId, "Some group", new List <string> { "c#" }, "Very interesting", 3, 100, false, GroupType.Lecture); userFacade.Invite(creatorId, invitedId, createdGroupId, MemberRole.Member); var invitation = userFacade.GetAllInvitationsForUser(invitedId).ToList()[0]; //Act userFacade.ChangeInvitationStatus(invitedId, invitation.Id, InvitationStatus.Accepted); //Assert var createdGroup = _groupRepository.GetGroupById(createdGroupId); Assert.AreEqual(2, createdGroup.Members.Count); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { groupFacade = new GroupFacade(); // Set username theUser = (person)Session["user"]; //lblWelcomeUsername.Text = theUser.Name; hdPersondId.Value = theUser.Id.ToString(); hdPersondUserName.Value = theUser.Name; // Get group ID from url parameter Boolean goodGroupId = false; int groupId; goodGroupId = int.TryParse(Request.Params["groupID"], out groupId); if (goodGroupId) { hdGroupId.Value = groupId.ToString(); } } }
public async Task <ActionResult> Create(GroupDto group) { group.Picture = "/Img/default.jpg"; var newGroupId = await GroupFacade.CreateGroup(Guid.Empty, group, true); return(RedirectToAction("Details", new { id = newGroupId })); }
protected void Page_Load(object sender, EventArgs e) { person currentUser; // faudrait encore fait un helper pour ça if (Session["user"] != null) { currentUser = (person)Session["user"]; if (homeFacade == null) { homeFacade = new HomeFacade(); } if (groupFacade == null) { groupFacade = new GroupFacade(); } renderGroupsToPage(currentUser); } else { // Redirect to home page... (no login) // Todo: put in helper function in master ^ v Response.Redirect("Index.aspx"); } }
public UserType(UserGroupFacade userGroupFacade, UserMarkFacade userMarkFacade, UserRoleFacade userRoleFacade, GroupFacade groupFacade, GroupSubjectFacade groupSubjectFacade) { Field(x => x.Id); Field <StringGraphType>("login", resolve: context => context.Source.Login); Field <StringGraphType>("password", resolve: context => context.Source.Password); Field <StringGraphType>("firstName", resolve: context => context.Source.FirstName); Field <StringGraphType>("lastName", resolve: context => context.Source.LastName); Field <StringGraphType>("secondName", resolve: context => context.Source.SecondName); Field <ListGraphType <GroupType> >("group", resolve: context => { return(userGroupFacade.GetByUserId(context.Source.Id, groupFacade)); } ); Field <ListGraphType <UserMarkType> >("userMarks", resolve: context => userMarkFacade.GetByUserId(context.Source.Id) ); Field <UserMarkType>("userMark", arguments: new QueryArguments(new QueryArgument <IntGraphType> { Name = "id" }), resolve: context => userMarkFacade.GetById(context.GetArgument <int>("id"))); Field <UserRoleType>( "userRole", resolve: context => userRoleFacade.GetById(context.Source.UserRoleId) ); }
public Queries(MarkFacade markFacade, UserFacade userFacade, GroupFacade groupFacade, GroupSubjectFacade groupSubjectFacade, NotificationFacade notificationFacade, NotificationStudentFacade notificationStudentFacade, SubjectFacade subjectFacade, UserGroupFacade userGroupFacade, UserMarkFacade userMarkFacade, UserRoleFacade userRoleFacade) { AddMarkQueries(markFacade); AddUserQueries(userFacade, userRoleFacade); AddGroupQueries(groupFacade); AddGroupSubjectQueries(groupSubjectFacade, subjectFacade, userFacade); AddNotificationQueries(notificationFacade); AddNotificationStudentQueries(notificationStudentFacade); AddSubjectQueries(subjectFacade); AddUserGroupQueries(userGroupFacade); AddUserMarkQueries(userMarkFacade); AddUserRoleQueries(userRoleFacade); AddAuthorizeQueries(userFacade, userRoleFacade); }
public void TryToAcceptTeacherInvitationWithAlreadyFoundTeacher_GetException() { //Arrange var publisher = new Mock <IEventPublisher>(); var groupFacade = new GroupFacade(_groupRepository, _userRepository, _sanctionRepository, new GroupSettings(1, 100, 0, 1000), publisher.Object); var accountFacade = new AccountFacade(_keysRepository, _userRepository, _emailSender.Object, userSettings); var userFacade = new UserFacade(_userRepository, _groupRepository, _eventRepository, _publisher.Object); var creatorId = accountFacade.RegUser("Creator", new Credentials("email1", "password"), false); var teacherId = accountFacade.RegUser("Teacher", new Credentials("email2", "password"), true); var newTeacherId = accountFacade.RegUser("Teacher", new Credentials("email3", "password"), true); var createdGroupId = groupFacade.CreateGroup(creatorId, "Some group", new List <string> { "c#" }, "Very interesting", 1, 100, false, GroupType.Lecture); userFacade.Invite(creatorId, newTeacherId, createdGroupId, MemberRole.Teacher); var invitation = userFacade.GetAllInvitationsForUser(newTeacherId).ToList()[0]; //Act groupFacade.ApproveTeacher(teacherId, createdGroupId); userFacade.ChangeInvitationStatus(newTeacherId, invitation.Id, InvitationStatus.Accepted); }
public async Task <ActionResult> Edit(GroupImageModel model) { var user = await CharacterFacade.GetCharacterById(Guid.Parse(User.Identity.Name)); if (!(user.IsGroupAdmin && user.GroupId == model.Group.Id)) { return(RedirectToAction("NotAuthorized", "Error")); } try { var group = await GroupFacade.GetGroupAsync(model.Group.Id); var relativePath = group.Picture; if (model.File != null && model.File.ContentLength > 0) { var fileType = Path.GetExtension(model.File.FileName); var path = Path.Combine(Server.MapPath("~/Img/"), model.Group.Id + fileType); model.File.SaveAs(path); relativePath = "/Img/" + model.Group.Id + fileType; model.Group.Picture = relativePath; } model.Group.Picture = relativePath; await GroupFacade.Edit(model.Group); } catch (Exception ex) { ViewBag.Message = "ERROR: " + ex.Message.ToString(); } return(RedirectToAction("Index")); }
public GroupView(int groupID, int personID) { InitializeComponent(); controller = new MainController(); groupFacade = new GroupFacade(); activeGroupID = groupID; activePersonID = personID; fillTheFields(); fillTheMessagesDataGrid(); fillTheType(); // Vérification si l'utilisateur est administrateur du groupe bool isThisPersonTheGroupAdmin = groupFacade.PersonIsGroupAdmin(activePersonID, activeGroupID); if (isThisPersonTheGroupAdmin) { btnCloseGroup.Visible = true; btnDeleteFollower.Visible = true; } else { btnCloseGroup.Visible = false; btnDeleteFollower.Visible = false; } }
public GroupSubjectType(UserMarkFacade userMarkFacade, SubjectFacade subjectFacade, UserFacade userFacade, GroupFacade groupFacade) { Field(x => x.Id); Field <IntGraphType>( "orderNumber", resolve: context => context.Source.OrderNumber); Field <IntGraphType>( "dayOfWeek", resolve: context => context.Source.DayOfWeek); Field <ListGraphType <UserMarkType> >( "userMarks", resolve: context => userMarkFacade.GetByGroupSubjectId(context.Source.Id)); Field <SubjectType>("subject", resolve: context => subjectFacade.GetById(context.Source.SubjectId) ); Field <UserType>("teacher", resolve: context => userFacade.GetById(context.Source.TeacherId) ); Field <GroupType>("group", resolve: context => groupFacade.GetById(context.Source.GroupId) ); }
protected void Page_Load(object sender, EventArgs e) { if (groupFacade == null) { groupFacade = new GroupFacade(); } }
public async Task <ActionResult> Edit(Guid id) { var group = await GroupFacade.GetGroupAsync(id); return(View("Edit", new GroupImageModel { Group = group, File = null })); }
private void AddNotificationMutations(NotificationFacade notificationFacade, GroupFacade groupFacade, NotificationStudentFacade notificationStudentFacade) { Field <NotificationType>("addNotification", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <NotificationInputType> > { Name = "notification" }), resolve: context => { var notification = context.GetArgument <Notification>("notification"); notification.Group = groupFacade.GetById(notification.GroupId); return(notificationFacade.Add(notification));; } ); Field <NotificationType>("deleteNotification", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "notificationId" }), resolve: context => { var notificationId = context.GetArgument <int>("notificationId"); Notification notification = notificationFacade.GetById(notificationId); notificationStudentFacade.DeleteByNotification(notification); return(notificationFacade.Delete(notification)); } ); Field <ListGraphType <NotificationType> >("notificationsForStudent", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "studentId" }, new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "groupId" } ), resolve: context => { var groupId = context.GetArgument <int>("groupId"); var studentId = context.GetArgument <int>("studentId"); IEnumerable <Notification> notifications = notificationFacade.GetByGroupId(groupId); List <Notification> notificationList = new List <Notification>(); foreach (var notification in notifications) { if (!notificationStudentFacade.getByUserIdAndNotificationId(studentId, notification.Id)) { notificationList.Add(notification); notificationStudentFacade.Add(new NotificationStudent { NotificationId = notification.Id, StudentId = studentId }); } } return(notificationList); } ); }
public UserGroupType(GroupFacade groupFacade, UserFacade userFacade) { Field(x => x.Id); Field <GroupType>("group", resolve: context => groupFacade.GetById(context.Source.GroupId) ); Field <UserType>("user", resolve: context => userFacade.GetById(context.Source.UserId) ); }
public static string GetGroupMessages() { JavaScriptSerializer TheSerializer = new JavaScriptSerializer(); //Si groupFacade est null on l'instancie if (groupFacade == null) { groupFacade = new GroupFacade(); } //Si homeFacade est null on l'instancie if (homeFacade == null) { homeFacade = new HomeFacade(); } //On ajoute a la liste following tous les groups aux quels l'utilisateur participe following = homeFacade.GetPersonGroups(theUser.Id); //On instance une nouvelle liste qui contiendera les id des groups aux quels l'utilisateur participe groupsId = new List <int>(); //On initialise une nouvelle liste, qui contiendera des objets de MessageDetail List <MessageDetail> listMessageDetail = new List <MessageDetail>(); //Pour chaque group dans la liste following foreach (group followingId in following) { //On initialise une nouvelle liste qui contiendera les messages List <Message> listMessage = new List <Message>(); //On ajoute dans la liste groupMessages tous les messages des groups dans lesquels l'utilisateur participe groupMessages = groupFacade.GetGroupChatHistory(followingId.Id); //Pour chaque message de la liste groupMessages foreach (chathistory msg in groupMessages) { //..On ajoute dans la liste listMessage les messages qui se trouve dans la liste prit a partir des messages de groupe listMessage.Add(new Message { authorName = msg.person.Name, message = msg.Message, dateMessage = msg.CreationDate.ToString() }); } MessageDetail messageDetail = new MessageDetail { groupId = followingId.Id, Message = listMessage }; listMessageDetail.Add(messageDetail); } // TheSerializer.Serialize(personId); return(TheSerializer.Serialize(listMessageDetail)); }
public async Task <ActionResult> PostToGroup(string message) { var user = await CharacterFacade.GetCharacterById(Guid.Parse(User.Identity.Name)); if (user != null && user.GroupId.HasValue) { await GroupFacade.CreatePost(new GroupPostDto { GroupId = user.GroupId.Value, CharacterId = user.Id, Text = message, Timestamp = DateTime.Now }); return(RedirectToAction("Index")); } return(RedirectToAction("NotAuthorized", "Error")); }
public async Task <ActionResult> Join(Guid id) { var user = await CharacterFacade.GetCharacterById(Guid.Parse(User.Identity.Name)); if (user != null && !user.GroupId.HasValue) { await GroupFacade.AddToGroup(user.Id, id); return(RedirectToAction("Index")); } return(RedirectToAction("NotAuthorized", "Error")); }
public async Task <ActionResult> Delete(Guid id) { var user = await CharacterFacade.GetCharacterById(Guid.Parse(User.Identity.Name)); if (user != null && user.IsGroupAdmin && user.GroupId == id) { await GroupFacade.RemoveGroup(id); return(RedirectToAction("List")); } return(RedirectToAction("NotAuthorized", "Error")); }
public async Task <ActionResult> Create(GroupDto group) { var user = await CharacterFacade.GetCharacterById(Guid.Parse(User.Identity.Name)); if (user.GroupId != null) { return(RedirectToAction("NotAuthorized", "Error")); } group.Picture = "/Img/default.jpg"; var newGroupId = await GroupFacade.CreateGroup(Guid.Parse(User.Identity.Name), group); return(RedirectToAction("Details", new { id = newGroupId })); }
public async Task <ActionResult> LeaveGroup(Guid characterId, Guid groupId) { var user = await CharacterFacade.GetCharacterById(Guid.Parse(User.Identity.Name)); if (user != null && user.GroupId.HasValue && user.GroupId == groupId) { if (user.IsGroupAdmin || characterId == user.Id) { await GroupFacade.RemoveFromGroup(characterId, groupId); } } return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit(Guid id) { var user = await CharacterFacade.GetCharacterById(Guid.Parse(User.Identity.Name)); if (user.IsGroupAdmin && user.GroupId == id) { var group = await GroupFacade.GetGroupAsync(id); return(View(new GroupImageModel { Group = group, File = null })); } return(RedirectToAction("NotAuthorized", "Error")); }
public async Task <ActionResult> List(int page = 1) { var filter = new GroupFilterDto { PageSize = PageSize, RequestedPageNumber = page }; var result = await GroupFacade.GetGroupsByFilterAsync(filter); // Paging ViewBag.RequestedPageNumber = result.RequestedPageNumber; ViewBag.PageCount = (int)Math.Ceiling((double)result.TotalItemsCount / (double)PageSize); // Paging END return(View("List", result.Items)); }
protected void Page_Load(object sender, EventArgs e) { if (groupFacade == null) { groupFacade = new GroupFacade(); } if (groupId == null) { groupId = int.Parse(Request.Params["GroupID"]); // still dirty } if (!Page.IsPostBack) { refreshGroupTasks(); } }
private void AddGroupQueries(GroupFacade groupFacade) { Field <ListGraphType <GroupType> >( "allGroups", resolve: context => groupFacade.GetAll() ); Field <GroupType>("group", arguments: new QueryArguments(new QueryArgument <IntGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <int?>("id"); return(id != null ? (groupFacade.GetById((int)id)) : null); } ); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (groupFacade == null) { groupFacade = new GroupFacade(); } int currentGroupId = int.Parse(Request.Params["groupID"]); // dirty still List <person> groupUsers = groupFacade.GetGroupFollowers(currentGroupId); panelFollowersInfo.Visible = false; followingListView.DataSource = groupUsers; followingListView.DataBind(); } }
public NotificationType(NotificationStudentFacade notificationStudentFacade, GroupFacade groupFacade) { Field(x => x.Id); Field <StringGraphType>("message", resolve: context => context.Source.Message); Field <GroupType>("group", resolve: context => groupFacade.GetById(context.Source.GroupId) ); Field <ListGraphType <NotificationStudentType> >( "notificationStudents", resolve: context => notificationStudentFacade.GetByNotificationId(context.Source.Id)); Field <NotificationStudentType>("notificationStudent", arguments: new QueryArguments(new QueryArgument <IntGraphType> { Name = "id" }), resolve: context => notificationStudentFacade.GetById(context.GetArgument <int>("id"))); }
public async Task <ActionResult> Details(Guid id) { var user = await CharacterFacade.GetCharacterById(Guid.Parse(User.Identity.Name)); var model = await GroupFacade.GetGroupAsync(id); if (model == null || user == null) { return(RedirectToAction("List")); } if (user.GroupId == model.Id) { ViewBag.GroupMember = true; if (user.IsGroupAdmin) { ViewBag.GroupAdmin = true; } } model.Wall = model.Wall.OrderByDescending(x => x.Timestamp).ToList(); return(View("Details", model)); }