Esempio n. 1
0
        public ActionResult Setting(GroupSettingViewModel groupSetting)
        {
            ViewBag.currentUser = User.Identity.GetUserId();
            var errors = ModelState.Values.SelectMany(v => v.Errors);

            if (ModelState.IsValid)
            {
                var filter = Builders <Group> .Filter.Where(x => x.Id.Equals(new ObjectId(groupSetting.Id)));

                var update = Builders <Group> .Update.
                             Set(x => x.GroupName, groupSetting.GroupName).
                             Set(x => x.Description, groupSetting.Description).
                             Set(x => x.GroupType, groupSetting.GroupType).
                             Set(x => x.Text, CommonHelper.SearchString(groupSetting.GroupName.ToLower()));

                Context.Groups.UpdateOneAsync(filter, update);
                var editGroup = Context.Groups.Find(x => x.Id.Equals(new ObjectId(groupSetting.Id))).FirstOrDefault();
                return(RedirectToAction("MainPage", "Groups", editGroup.Id));
            }
            var group = Context.Groups.Find(x => x.Id.Equals(new ObjectId(groupSetting.Id))).FirstOrDefault();

            ViewBag.cloudinary = cloudinary;
            ViewBag.group      = group;
            return(View(groupSetting));
        }
Esempio n. 2
0
        //
        // GET: /Groups/id/Setting
        public ActionResult Setting(string id)
        {
            var allGroup = Context.Groups.Find(_ => true).ToList();

            if (allGroup.Where(x => x.Id.Equals(id)).Any() == false)
            {
                ViewBag.errorMessage = "Không có kết quả!";
                return(View("NotFoundError"));
            }
            else
            {
                var group = Context.Groups.Find(x => x.Id.Equals(new ObjectId(id))).FirstOrDefault();
                if (group.Locked)
                {
                    return(RedirectToAction("LockedPage", "Home"));
                }
                else
                {
                    var groupSetting = new GroupSettingViewModel()
                    {
                        Id          = group.Id,
                        CreatorId   = group.CreatorId,
                        GroupName   = group.GroupName,
                        Description = group.Description,
                        Lock        = group.Locked,
                        Tag         = group.Tag,
                        GroupType   = group.GroupType
                    };
                    ViewBag.groupReport = GroupReportContent();
                    ViewBag.cloudinary  = cloudinary;
                    var currentUser = User.Identity.GetUserId();
                    ViewBag.currentUser = currentUser;
                    var listGroupOfUser = new List <Group>();
                    foreach (var grp in allGroup)
                    {
                        if (grp.GroupMembers.Find(x => x.UserId.Equals(currentUser)) != null)
                        {
                            listGroupOfUser.Add(grp);
                        }
                    }
                    ViewBag.listGroupOfUser = listGroupOfUser;
                    ViewBag.group           = group;
                    var allUser = Context.Users.Find(_ => true).ToList();
                    ViewBag.allUser = allUser;
                    return(View(groupSetting));
                }
            }
        }
Esempio n. 3
0
        //
        // GET: /Groups/id/Setting
        public ActionResult Setting(string id)
        {
            var group        = Context.Groups.Find(x => x.Id.Equals(new ObjectId(id))).FirstOrDefault();
            var groupSetting = new GroupSettingViewModel()
            {
                Id          = group.Id,
                CreatorId   = group.CreatorId,
                GroupName   = group.GroupName,
                Description = group.Description,
                Lock        = group.Locked,
                Tag         = group.Tag,
                GroupType   = group.GroupType
            };

            ViewBag.currentUser = User.Identity.GetUserId();
            var listMember = new List <GroupMembersViewModel>();

            listMember = group.GroupMembers;
            var listRequest = new List <string>();

            listRequest         = group.ListJoinRequest;
            ViewBag.listMember  = listMember;
            ViewBag.listRequest = listRequest;
            var allUser = Context.Users.Find(_ => true).ToList();

            ViewBag.allUser = allUser;
            //var groupMembersViewModel = new List<GroupMembersViewModel>();
            //foreach (var user in allUser)
            //{
            //    groupMembersViewModel.Add(new GroupMembersViewModel()
            //    {
            //        UserId = user.Id,
            //        UserName = user.UserName,
            //        IsSelected = group.GroupMembers.Where(x => x.UserId == user.Id).Any()
            //    });
            //}
            //group.GroupMembers = groupMembersViewModel;
            return(View(groupSetting));
        }
Esempio n. 4
0
        //
        // GET: /Groups/id/Setting
        public ActionResult Setting(string id)
        {
            var group        = Context.Groups.Find(x => x.Id.Equals(new ObjectId(id))).FirstOrDefault();
            var groupSetting = new GroupSettingViewModel()
            {
                Id          = group.Id,
                CreatorId   = group.CreatorId,
                GroupName   = group.GroupName,
                Description = group.Description,
                Lock        = group.Locked,
                Tag         = group.Tag,
                GroupType   = group.GroupType
            };

            ViewBag.currentUser = User.Identity.GetUserId();
            ViewBag.cloudinary  = cloudinary;
            ViewBag.group       = group;
            var allUser = Context.Users.Find(_ => true).ToList();

            ViewBag.allUser = allUser;
            return(View(groupSetting));
        }