protected bool CheckViewGroup(GroupObject groupObject) { bool isAllow = false; if (groupObject.IsPublic) { isAllow = true; } else { if (Session["user"] != null) { var userID = ((UserObject)Session["user"]).Id; IUserService userService = MvcUnityContainer.Container.Resolve(typeof(IUserService), "") as IUserService; var user = userService.Load(userID); foreach (var userGroup in user.ListUserGroup) { if (userGroup.GroupId.Equals(groupObject.Id) && userGroup.IsApprove == UserGroupStatus.Approve) { isAllow = true; } } } } return isAllow; }
public ActionResult UpdateSetting(GroupObject group) { var groupOld = groupService.Load(group.Id); groupOld.IsPublic = group.IsPublic; groupOld.GroupName = group.GroupName; groupOld.Description = group.Description; groupService.Save(groupOld); return RedirectToAction("Setting", "Group", new { id = group.Id }); }
public ActionResult Create(GroupObject group) { IUserService userService = MvcUnityContainer.Container.Resolve(typeof(IUserService), "") as IUserService; IGroupRoleService groupRoleService = MvcUnityContainer.Container.Resolve(typeof(IGroupRoleService), "") as IGroupRoleService; var groupRole = groupRoleService.LoadByName(GroupRoleType.Owner); string userId = ((UserObject)Session["user"]).Id; group.Id = Guid.NewGuid().ToString(); group.CreateDate = DateTime.Now; group.CreateBy = userId; group.IsPublic = false; var userGroup = new UserGroupObject(); userGroup.Id = Guid.NewGuid().ToString(); userGroup.UserId = userId; userGroup.GroupId = group.Id; userGroup.GroupName = group.GroupName; userGroup.Description = group.Description; userGroup.IsApprove = UserGroupStatus.Approve; userGroup.JoinDate = DateTime.Now; userGroup.ListGroupRole.Add(groupRole); group.ListUserGroup.Add(userGroup); var user = (UserObject)Session["user"]; user.ListUserGroup.Add(userGroup); userService.Save(user); groupService.Save(group); userGroupService.Save(userGroup); return RedirectToAction("Detail", "Group", new { id = group.Id }); }