public ActionResult Join(string id) { var user = (UserObject)Session["user"]; var group = groupService.Load(id); var userGroup = new UserGroupObject(); userGroup.Id = Guid.NewGuid().ToString(); userGroup.UserId = user.Id;; userGroup.GroupId = group.Id; userGroup.GroupName = group.GroupName; userGroup.Description = group.Description; userGroup.IsApprove = UserGroupStatus.JoinRequest; group.ListUserGroup.Add(userGroup); user.ListUserGroup.Add(userGroup); IUserService userService = MvcUnityContainer.Container.Resolve(typeof(IUserService), "") as IUserService; userService.Save(user); groupService.Save(group); userGroupService.Save(userGroup); return RedirectToAction("Detail", new { id }); }
public void Save(UserGroupObject userGroup) { session.Store(userGroup); session.SaveChanges(); }
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 }); }