public async Task <IActionResult> UpdateGroup(GroupDB group) { string userId = User.Claims.First(c => c.Type == "UserID").Value; var user = await _userManager.FindByIdAsync(userId); List <int> listcharacterkeygroup = new List <int>(); listcharacterkeygroup.Add(group.Fk_Leader); listcharacterkeygroup.AddRange(group.Fk_Followers); foreach (var account in user.Accounts) { if (account.CurrentCharacter.Fk_Group == group.Key && !listcharacterkeygroup.Contains(account.CurrentCharacter.Key)) { account.CurrentCharacter.Fk_Group = Guid.Empty; } else if (account.CurrentCharacter.Fk_Group != group.Key && listcharacterkeygroup.Contains(account.CurrentCharacter.Key)) { account.CurrentCharacter.Fk_Group = group.Key; } } await _userManager.UpdateAsync(user); await Database.Groups.ReplaceOneAsync(o => o.Key == group.Key, group); return(Ok(group)); }
public async Task <string> DeleteGroup(keymodel groupkey) { string userId = User.Claims.First(c => c.Type == "UserID").Value; var user = await _userManager.FindByIdAsync(userId); GroupDB grouptoDelete = _groups.FirstOrDefault(o => o.Key.ToString() == groupkey.key && o.FK_User.ToString() == userId); try { if (grouptoDelete != null) { foreach (var item in grouptoDelete.Fk_Followers) { user.Accounts.FirstOrDefault(o => o.CurrentCharacter.Key == item).CurrentCharacter.Fk_Group = Guid.Empty; } user.Accounts.FirstOrDefault(o => o.CurrentCharacter.Key == grouptoDelete.Fk_Leader).CurrentCharacter.Fk_Group = Guid.Empty; await _userManager.UpdateAsync(user); await Database.Groups.DeleteOneAsync(o => o.Key == grouptoDelete.Key); } } catch (Exception ex) { throw; } return(JsonSerializer.Serialize(grouptoDelete.Name)); }
public static bool DeleteAll() { List <Group> ListCache = List.ToArray().ToList(); Logger.Log.SystemMessage("Deleteing All Groups..."); foreach (Group ThisGroup in ListCache) { GroupDB.Delete(ThisGroup); } string GroupsDir = "./Database/Groups/"; Utilities.IO.PrepareDirectory("./Database/"); Utilities.IO.PrepareDirectory("./Database/Groups"); DirectoryInfo[] GroupsDirContents = new DirectoryInfo(GroupsDir).GetDirectories(); foreach (DirectoryInfo ThisDir in GroupsDirContents) { try { ThisDir.Delete(true); } catch (Exception e) { Logger.Log.Bug(e, String.Format("Directory In Use: {0}", ThisDir.FullName)); } } Logger.Log.SystemMessage("All Groups Deleted."); return(true); }
public void TestCaseSetup() { _group = new Group { Id = "00000000-0000-0000-0000-000000000000", AdminId = "2", Information = "Some product", Name = "Best", GroupBoards = null, GroupUsers = null }; _groupDB = new GroupDB { Id = "00000000-0000-0000-0000-000000000000", AdminId = "2", Information = "Some product", Name = "Best", Created = DateTime.UtcNow, Deleted = null, IsNotDeleted = true, Modified = DateTime.UtcNow, GroupBoards = null, GroupUsers = null }; _groupDB.GroupBoards = new List <GroupBoardDB> { new GroupBoardDB { Name = "Name", GroupProducts = new List <GroupProductDB> { new GroupProductDB { Information = "Information" } } } }; _groupDB.GroupUsers = new List <GroupUserDB> { new GroupUserDB { RightToCreateBoards = true } }; _groupRepositoryMock = new Mock <IGroupRepository>(); var config = new MapperConfiguration(cfg => { cfg.AddProfile(new GroupProfile()); cfg.AddProfile(new GroupBoardProfile()); cfg.AddProfile(new GroupProductProfile()); cfg.AddProfile(new GroupUserProfile()); cfg.AddProfile(new GroupCommentProfile()); }); _mapper = (new Mapper(config)).DefaultContext.Mapper; _groupService = new GroupService(_groupRepositoryMock.Object, _mapper); _selectedList = new List <GroupDB>(); }
public MapPermissionController() { this._mapManager = new MapDB(new Settings()); this._userService = new UserDB(new Settings()); this._groupManager = new GroupDB(new Settings()); //_userManager = UserManager; }
public static GroupViewModel GetGroup(int GroupId) { Group group = GroupDB.GetGroup(GroupId); return(new GroupViewModel(group.ID, group.Name, group.CreatedDate, group.Receviers.Select(r => r.UserName).ToList())); }
//check for any group updates and apply needed updates private void btnupdate_Click(object sender, EventArgs e) { int updated = 0; GroupDB gdb = new GroupDB(db); if (groupnumscbx.SelectedIndex != 2) { int x = 0; foreach (int index in attention) { if (index <= 0) // check that the kid is passed the group limit { gdb.updategroup(data[x][0], data[x][1]); createTableForGroup(groupnumscbx.SelectedIndex + 1); updated++; } x++; } } if (updated == 0) { MessageBox.Show("No changes needed"); } }
//populate the group stats for the user private void populategroupNums() { GroupDB gdb = new GroupDB(db); List <int> groupNums = gdb.numineachgroup(); List <string> groupNames = gdb.getgroupnames(); // use the correct group names set by the user GroupANum.Text = groupNames[0] + " : "; GroupBNum.Text = groupNames[1] + " : "; GroupCNum.Text = groupNames[2] + " : "; num1.Text = groupNums[0].ToString(); Num2.Text = groupNums[1].ToString(); Num3.Text = groupNums[2].ToString(); if (groupNums[0] >= gdb.getANum()) { num1.ForeColor = Color.Red; } else { num1.ForeColor = Color.LimeGreen; } if (groupNums[1] >= gdb.getBNum()) { Num2.ForeColor = Color.Red; } else { Num2.ForeColor = Color.LimeGreen; } if (groupNums[2] >= gdb.getCNum()) { Num3.ForeColor = Color.Red; } else { Num3.ForeColor = Color.LimeGreen; } StaffDB sdb = new StaffDB(db); StaffA.Text = groupNames[0] + " : " + sdb.countStaffbyid(1); StaffB.Text = groupNames[1] + " : " + sdb.countStaffbyid(2); StaffC.Text = groupNames[2] + " : " + sdb.countStaffbyid(3); List <Label> stafflabels = new List <Label>() { StaffA, StaffB, StaffC }; int counter = 0; foreach (Label label in stafflabels) { counter++; if (sdb.countStaffbyid(counter) < 2) { label.ForeColor = Color.Red; } } }
//update group names/group numbers private void btngapply_Click(object sender, EventArgs e) { GroupDB gdb = new GroupDB(db); gdb.updateGroupNames(NameA.Text, NameB.Text, NameC.Text); gdb.updateGroupNumbers(Convert.ToInt32(Anum.Value), Convert.ToInt32(bNum.Value), Convert.ToInt32(cNum.Value)); msg2lbl.Visible = true; }
public SearchController() { this._mapManager = new MapDB(new Settings()); this._userService = new UserDB(new Settings()); this._groupManager = new GroupDB(new Settings()); _searchObj = new Search(); //UserManager = UserManager; }
public static List <GroupViewModel> GetAllGroups() { List <GroupViewModel> groups = new List <GroupViewModel>(); List <Group> groupList = GroupDB.GetAllGroups(); groupList.ForEach(g => groups.Add(new GroupViewModel(g.ID, g.Name, g.CreatedDate, g.Receviers.Select(r => r.UserName).ToList()))); return(groups); }
public static void Save(string GroupName) { Group ThisGroup = GroupDB.FindGroup(GroupName); if (ThisGroup == GroupDB.NoGroup) { return; } ThisGroup.SaveAll(); }
protected void Page_Load(object sender, EventArgs e) { lblUpdateStatus.Text = string.Empty; if (!IsPostBack) { lstGroups.DataSource = GroupDB.GetAll(); lstGroups.DataTextField = "Group_Name"; lstGroups.DataValueField = "Group_ID"; lstGroups.DataBind(); } }
//populate the three group types private void populateGroupNumscbx() { groupnumscbx.Items.Clear(); GroupDB gdb = new GroupDB(db); List <string> groupNames = gdb.getgroupnames(); groupnumscbx.Items.Add(groupNames[0]); groupnumscbx.Items.Add(groupNames[1]); groupnumscbx.Items.Add(groupNames[2]); groupnumscbx.SelectedIndex = 0; }
//setup the groups on load private void setGroups() { GroupDB gdb = new GroupDB(db); List <string> groupNames = gdb.getgroupnames(); NameA.Text = groupNames[0]; NameB.Text = groupNames[1]; NameC.Text = groupNames[2]; Anum.Value = gdb.getANum(); bNum.Value = gdb.getBNum(); cNum.Value = gdb.getCNum(); }
public async Task <GroupDB> CreateGroupAsync(GroupDB group) { string userId = User.Claims.First(c => c.Type == "UserID").Value; var user = await _userManager.FindByIdAsync(userId); group.Key = Guid.NewGuid(); await CreateConfigAsync(group.Key); group.Fk_Configuration = Database.ConfigsGroup.Find(FilterDefinition <ConfigGroupDB> .Empty).ToList().FirstOrDefault(o => o.Fk_Group == group.Key).Key; group.FK_User = Guid.Parse(userId); int level = 0; foreach (var charactersId in group.Fk_Followers) { foreach (Account account in user.Accounts) { var character = account.Characters.FirstOrDefault(o => o.Key == charactersId); var principalChaarcter = account.CurrentCharacter; if (character != null) { level += character.Level; character.Fk_Group = group.Key; principalChaarcter.Fk_Group = group.Key; } } } var idLeader = group.Fk_Leader; foreach (var account in user.Accounts) { var leader = account.Characters.FirstOrDefault(o => o.Key == idLeader); if (leader != null) { level += leader.Level; leader.Fk_Group = group.Key; account.CurrentCharacter.Fk_Group = group.Key; } } group.groupLevel = level; await _userManager.UpdateAsync(user); await Database.Groups.InsertOneAsync(group); return(group); }
protected void cmdAddNew_Click(object sender, EventArgs e) { GroupInfo info = new GroupInfo(); info.Group_Name = txtName.Text.Trim(); info.Group_Description = txtDes.Text; //try //{ txtID.Text = GroupDB.Insert(info).ToString(); lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; //} //catch //{ // lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; //} }
protected void Page_Load(object sender, EventArgs e) { groupInfo = GroupDB.GetInfo(ConvertUtility.ToInt32(Request.QueryString["groupid"])); if (groupInfo == null) { Response.Redirect(AppEnv.ADMIN_PATH); } txtGroupName.Text = groupInfo.Group_Name; lblUpdateStatus.Text = string.Empty; if (!IsPostBack) { lstRoles.Items.Clear(); CmdDB.FillToListBox(lstRoles.Items); } }
protected void Page_Load(object sender, EventArgs e) { groupInfo = GroupDB.GetInfo(ConvertUtility.ToInt32(Request.QueryString["groupid"])); if (groupInfo == null) { Response.Redirect(AppEnv.ADMIN_PATH); } txtGroupName.Text = groupInfo.Group_Name; lblUpdateStatus.Text = string.Empty; if (!IsPostBack) { lstUsers.DataSource = UserDB.GetAll(); lstUsers.DataTextField = "User_Email"; lstUsers.DataValueField = "User_ID"; lstUsers.DataBind(); } }
public async Task <GroupDTO> AddGroupAsync(GroupDTO groupDTO) { SpecializationDB spec = _context.Specialization.Where(c => c.nameOfSpecialization == groupDTO.nameOfSpecialization) .FirstOrDefault(); ProfessionDB prof = _context.Profession.Where(c => c.nameOfProffession == groupDTO.ProfessionLastName) .FirstOrDefault(); if (spec == null || prof == null) { return(null); } GroupDB group = new GroupDB { id = groupDTO.id, info = groupDTO.info, SpecializationDB = spec, ProfessionDB = prof, CountCadets = groupDTO.CountCadets, numberOfGroup = groupDTO.numberOfGroup, ProfessionDBid = prof.id, SpecializationDBid = spec.id }; try { _context.Group.Add(group); await _context.SaveChangesAsync(); return(groupDTO); } catch (DbUpdateConcurrencyException) { if (!GroupDBExists(group.id)) { return(null); } else { throw; } } }
public static void LoadAll() { string GroupsDir = "./Database/Groups/"; Utilities.IO.PrepareDirectory("./Database/"); Utilities.IO.PrepareDirectory("./Database/Groups"); DirectoryInfo[] GroupsDirContents = new DirectoryInfo(GroupsDir).GetDirectories(); Logger.Log.SystemMessage("Loading All Groups..."); if (GroupsDirContents.Length == 0) { Logger.Log.SystemMessage(" No Groups are in the Database."); return; } foreach (DirectoryInfo ThisDir in GroupsDirContents) { GroupDB.Load(ThisDir.Name); } Logger.Log.SystemMessage(" All Groups Loaded."); }
protected void cmdUpdate_Click(object sender, EventArgs e) { GroupInfo info = GroupDB.GetInfo(ConvertUtility.ToInt32(txtID.Text)); if (info == null) { return; } info.Group_Name = txtName.Text.Trim(); info.Group_Description = txtDes.Text; try { GroupDB.Update(info); lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; } catch { lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; } }
protected void dtgGroups_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "edit") { GroupInfo group = GroupDB.GetInfo(Convert.ToInt32(e.Item.Cells[0].Text)); if (group == null) { cmdEmpty_Click(null, null); return; } txtID.Text = group.Group_ID.ToString(); txtName.Text = group.Group_Name; txtDes.Text = group.Group_Description; } if (e.CommandName == "del") { try { GroupDB.Delete(Convert.ToInt32(e.Item.Cells[0].Text)); lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; cmdEmpty_Click(null, null); } catch { lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; } } if (e.CommandName == "roles") { Response.Redirect(AppEnv.ADMIN_CMD + "maingroupcmdroles&groupid=" + e.Item.Cells[0].Text); } if (e.CommandName == "members") { Response.Redirect(AppEnv.ADMIN_CMD + "maingroupmembers&groupid=" + e.Item.Cells[0].Text); } if (e.CommandName == "stores") { Response.Redirect(AppEnv.ADMIN_CMD + "cmdusergroupstoremanagement&groupid=" + e.Item.Cells[0].Text); } }
public IEnumerable <Map> searchMapsFunc(string mapName, ObjectId userId) { List <Map> maps = new List <Map>(); IEnumerable <Map> mapss = _allMaps; foreach (var item in mapss) { if (item.Name.ToLower().Contains(mapName.ToLower())) { if (item.Permissions.Users.Keys.Contains(userId)) { maps.Add(item); } else { var allMapGroupsId = item.Permissions.Groups.Keys; var allUserGroups = new GroupDB(new Settings()).GetAllGroupsOfUser(userId); foreach (var group in allUserGroups) { if (allMapGroupsId.Contains(group.Id)) { maps.Add(item); } } } } var nodes = item.Model["nodeDataArray"]; foreach (var node in nodes.AsBsonArray) { if (node["text"].ToString().ToLower().Contains(mapName.ToLower()) && !maps.Contains(item)) { maps.Add(item); } } } return(maps); }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); dtgGroups.DataSource = GroupDB.GetAll(); dtgGroups.DataBind(); }
public static bool LeaveGroup(string UserId, int GroupId) { return(GroupDB.LeaveGroup(UserId, GroupId)); }
public static bool CreateGroup(string UserId, string GroupName) { return(GroupDB.CreateGroup(UserId, GroupName)); }
public MapController() { this._mapManager = new MapDB(new Settings()); this._groupManager = new GroupDB(new Settings()); this._folderManeger = new MapFolderDB(new Settings()); }
public async Task <SideNav> CreateSideNavUserAsync() { string userId = User.Claims.First(c => c.Type == "UserID").Value; var user = await _userManager.FindByIdAsync(userId); List <Guid> listGroupId = new List <Guid>(); List <Guid> listAccount = new List <Guid>(); SideNav sidenav = new SideNav(); sidenav.items = new List <SideNavItem>(); foreach (var account in user.Accounts) { if (account.CurrentCharacter != null) { if (account.CurrentCharacter.Fk_Group != Guid.Empty && _groups.FindIndex(o => o.Key == account.CurrentCharacter.Fk_Group) != -1 && !listGroupId.Contains(account.CurrentCharacter.Fk_Group)) { listGroupId.Add(account.CurrentCharacter.Fk_Group); } else if (account.CurrentCharacter.Fk_Group == Guid.Empty) { SideNavItem item = new SideNavItem() { Id = account.CurrentCharacter.Key.ToString(), isGroup = false, Name = account.CurrentCharacter.Name, State = ControllersModel.Enum.SideNavState.CONNECTED }; sidenav.items.Add(item); } } } foreach (var groupId in listGroupId) { GroupDB group = _groups.Find(o => o.Key == groupId) as GroupDB; SideNavItem item = new SideNavItem() { Id = groupId.ToString(), Name = group.Name, isGroup = true, State = ControllersModel.Enum.SideNavState.CONNECTED, Children = new List <SideNavItem>() }; foreach (var account in user.Accounts) { if (account.CurrentCharacter != null) { if (account.CurrentCharacter.Fk_Group == groupId) { SideNavItem ChildItem = new SideNavItem() { Id = account.CurrentCharacter.Key.ToString(), isGroup = false, Name = account.CurrentCharacter.Name, State = ControllersModel.Enum.SideNavState.CONNECTED }; item.Children.Add(ChildItem); } } } sidenav.items.Add(item); } return(sidenav); }
public static bool JoinGroup(string UserId, int GroupId) { return(GroupDB.JoinGroup(UserId, GroupId)); }