Example #1
0
        public void SendGroupRequest(int id)
        {
            var com    = new GroupCommunication();
            var userId = User.Identity.GetUserId();

            com.SetGroupRequestStatus(userId, id, GroupStatus.Waiting);
        }
Example #2
0
        public PartialViewResult _GroupRequests(int id)
        {
            var model  = new List <RequestViewModel>();
            var userId = User.Identity.GetUserId();
            var com    = new GroupCommunication();
            var group  = com.GetUsersGroups(userId).FirstOrDefault(x => x.Id == id);

            if (group != null)
            {
                var members = com.GetAllGroupMembers(group.Id, GroupStatus.Waiting);
                foreach (var member in members)
                {
                    if (member.Group.CreatorId == userId)
                    {
                        var requset = new RequestViewModel
                        {
                            UserName  = member.User.UserName,
                            FirstName = member.User.FirstName,
                            LastName  = member.User.LastName,
                            Email     = member.User.Email,
                            MemberId  = member.Id,
                            GroupId   = group.Id
                        };

                        model.Add(requset);
                    }
                }
            }


            return(PartialView("_GroupRequests", model));
        }
Example #3
0
        public PartialViewResult _GroupInformation(int id)
        {
            var userId = User.Identity.GetUserId();
            var com    = new GroupCommunication();

            var group = com.GetGroup(id);

            var member = com.GetGroupMember(userId, id);

            var name  = group.Creator.FirstName + " " + group.Creator.LastName;
            var model = new GroupsViewModel
            {
                GroupName     = group.Name,
                Administrator = name,
                Description   = group.Description,
                TimeCreated   = group.TimeCreated,
                MemberShip    = member.MembershipTime
            };

            if (group.Creator.UserName.Equals(User.Identity.GetUserName()))
            {
                model.MemberStatus = "Administrator";
            }
            else
            {
                model.MemberStatus = "User";
            }

            return(PartialView("_GroupInformation", model));
        }
Example #4
0
        public PartialViewResult _GroupMembers(int id)
        {
            var com     = new GroupCommunication();
            var model   = new List <string>();
            var members = com.GetAllGroupMembers(id, GroupStatus.Accepted);

            foreach (var member in members)
            {
                var name = member.User.FirstName + " " + member.User.LastName;
                model.Add(name);
            }
            return(PartialView("_GroupMembers", model));
        }
Example #5
0
        public PartialViewResult SendGroupMessage(int groupId, string messageText)
        {
            var com     = new GroupCommunication();
            var userId  = User.Identity.GetUserId();
            var message = new Message
            {
                Text        = messageText,
                TimeCreated = DateTime.Now
            };

            com.SendGroupMessage(userId, message, groupId);

            return(_GroupMessages(groupId));
        }
Example #6
0
        public PartialViewResult _SearchGroupResult(string id, string keyword)
        {
            if (id != null)
            {
                SendGroupRequest(int.Parse(id));
            }

            var          modelList = new List <GroupsViewModel>();
            var          userId    = User.Identity.GetUserId();
            var          com       = new GroupCommunication();
            List <Group> mygroups;

            if (keyword == null)
            {
                ViewBag.keyword = null;
                mygroups        = com.GetAllGroups();
            }
            else
            {
                ViewBag.keyword = keyword;
                mygroups        = com.GetGroups(keyword);
            }


            foreach (var group in mygroups)
            {
                var model = new GroupsViewModel
                {
                    GroupId     = group.Id,
                    GroupName   = group.Name,
                    Description = group.Description,
                    TimeCreated = group.TimeCreated
                };
                var member = com.GetGroupMember(userId, group.Id);
                if (member != null)
                {
                    model.GroupStatus = member.Status;
                }
                modelList.Add(model);
            }
            return(PartialView("_ShowGroups", modelList));
        }
Example #7
0
        public PartialViewResult _ShowMyGroups()
        {
            var modelList = new List <GroupsViewModel>();
            var useId     = User.Identity.GetUserId();
            var groupcom  = new GroupCommunication();
            var mygroups  = groupcom.GetUsersGroups(useId);

            foreach (var group in mygroups)
            {
                var model = new GroupsViewModel
                {
                    GroupId     = group.Id,
                    GroupName   = group.Name,
                    Description = group.Description,
                    TimeCreated = group.TimeCreated
                };

                modelList.Add(model);
            }
            return(PartialView("_ShowMyGroups", modelList));
        }
Example #8
0
        public void DenyGroupRequest(int id)
        {
            var com = new GroupCommunication();

            com.ChangeMemberStatus(id, GroupStatus.Denied);
        }
Example #9
0
        public void AcceptGroupRequest(int id)
        {
            var com = new GroupCommunication();

            com.ChangeMemberStatus(id, GroupStatus.Accepted);
        }