public GroupUserList SelectAll() { lgroupu = new GroupUserList(); cmd.CommandText = "SELECT * From GroupUser"; lgroupu = new GroupUserList(base.Select()); return(lgroupu); }
public async Task AddUserList(string groupGuid, string emoji, int?amount, params string[] description) { Guid guid = Guid.Parse(groupGuid); if (_groupService.TryGetGroup(Context.Guild.Id, guid, out var group)) { if (group.Host.Id != Context.User.Id) { return; } if (!group.UserLists.Any(x => x.JoinEmote.Name == emoji)) { var newList = new GroupUserList() { Users = new List <SocketGuildUser>(), JoinEmote = new Emoji(emoji), UserLimit = amount, Description = (description.Length > 0) ? string.Join(' ', description) : string.Empty }; group.UserLists.Add(newList); await _groupService.ReplaceWithNewerGroup(group); await group.PresentationMessage.AddReactionAsync(newList.JoinEmote); } else { await ReplyAsync("There is already list with such emoji present."); } } else { await ReplyAsync("No groups with such ID were found"); } }
public override void Delete(BaseEntity entity) { Person u = entity as Person; GroupUserDB gudb = new GroupUserDB(); GroupUserList gul = new GroupUserList(); gul = gudb.SelectByPerson(u); foreach (GroupUser g in gul) { gudb.Delete(g); } CommentsDB cdb = new CommentsDB(); CommentsList lc = cdb.CommentsByPerson(u); foreach (Comments c in lc) { cdb.Delete(c); } MsgsDB mdb = new MsgsDB(); MsgsList ml = new MsgsList(); ml = mdb.MsgsBySender(u); foreach (Msgs m in ml) { mdb.Delete(m); } base.Delete(entity); }
public static GroupUser SelectByID(int id) { if (lgroupu == null) { GroupUserDB db = new GroupUserDB(); lgroupu = db.SelectAll(); } GroupUser groupu = lgroupu.Find(c => c.ID == id); return(groupu); }
public GroupUserListRefence(GroupUserList groupUserList) { Description = groupUserList.Description; Emote = groupUserList.JoinEmote.Name; UserIds = new List <ulong>(); for (int i = 0; i < groupUserList.Users.Count; i++) { UserIds.Add(groupUserList.Users[i].Id); } UserLimit = groupUserList.UserLimit; }
public GroupUserList SelectByPerson(Person p) { lgroupu = new GroupUserList(); cmd.CommandText = "SELECT * From GroupUser WHERE User = @p"; cmd.Parameters.Add(new OleDbParameter("@p", p.ID)); lgroupu = new GroupUserList(base.Select()); return(lgroupu); //if (lgroupu == null) //{ // GroupUserDB db = new GroupUserDB(); // lgroupu = db.SelectAll(); //} //GroupUserList gul = new GroupUserList(lgroupu.FindAll(gu => gu.User == p)); //return gul; }
public questStatus Read(DbMgrTransaction trans, GroupId groupId, out GroupUserList groupUserList) { // Initialize questStatus status = null; groupUserList = null; // Read groupUser status = _dbGroupUsersMgr.Read(trans, groupId, out groupUserList); if (!questStatusDef.IsSuccess(status)) { return(status); } return(new questStatus(Severity.Success)); }
public UserDataHandler GetUserByToken(string token) { try { var tokenActive = _context.TokenLogs.FirstOrDefault(x => x.Token == token && x.Active == true && DateTime.Now < x.ValidThru); if (tokenActive == null) { return(null); } else { var user = _context.Users.FirstOrDefault(x => x.Id == tokenActive.UserId); var groups = _context.UserGroups.Where(y => y.UserId == user.Id).ToList(); List <GroupUserList> groupsresult = new List <GroupUserList>(); foreach (var g in groups) { var group = _context.Groups.FirstOrDefault(gr => gr.Id == g.GroupId); GroupUserList groupHandler = new GroupUserList(); groupHandler.Id = g.Id; groupHandler.Descricao = group.Description; groupHandler.Funcao = _context.Functions.FirstOrDefault(y => y.Id == group.FunctionId)?.Description; groupHandler.Inserido = g.CreationDate; groupsresult.Add(groupHandler); } UserDataHandler response = new UserDataHandler { Id = user.Id, Name = user.Name, CPF = user.CPF, Group = groupsresult, Token = token }; return(response); } } catch (System.Exception) { throw; } }
public List <UserList> GetUsers() { try { List <UserList> response = new List <UserList>(); var users = _context.Users.ToList(); foreach (var x in users) { UserList user = new UserList(); user.Id = x.Id; user.Name = x.Name; user.CPF = x.CPF; var groups = _context.UserGroups.Where(y => y.UserId == x.Id).ToList(); List <GroupUserList> groupsresult = new List <GroupUserList>(); foreach (var g in groups) { var group = _context.Groups.FirstOrDefault(gr => gr.Id == g.GroupId); GroupUserList groupHandler = new GroupUserList(); groupHandler.Id = g.Id; groupHandler.Descricao = group.Description; groupHandler.Funcao = _context.Functions.FirstOrDefault(y => y.Id == group.FunctionId)?.Description; groupHandler.Inserido = g.CreationDate; groupsresult.Add(groupHandler); } user.Group = groupsresult; response.Add(user); } return(response); } catch (System.Exception e) { var errorMessage = e.InnerException; throw; } }
public questStatus Read(GroupId groupId, out GroupUserList groupUserList) { // Initialize questStatus status = null; groupUserList = null; // Get group Group group = null; status = _dbGroupsMgr.Read(groupId, out group); if (!questStatusDef.IsSuccess(status)) { return(status); } // Get group users using (FMSEntities dbContext = new FMSEntities()) { List <Quest.Services.Dbio.FMS.GroupUsers> _groupUserList = null; status = read(dbContext, groupId, out _groupUserList); if (!questStatusDef.IsSuccess(status)) { return(status); } groupUserList = new GroupUserList(); groupUserList.Group = group; foreach (Quest.Services.Dbio.FMS.GroupUsers _groupUser in _groupUserList) { // Get user UserId userId = new UserId(_groupUser.UserId); User user = null; status = _dbUsersMgr.Read(userId, out user); if (!questStatusDef.IsSuccess(status)) { return(status); } groupUserList.UserList.Add(user); } } return(new questStatus(Severity.Success)); }