internal static List <DatabaseModels.Group> GetGroupsFromUser(NoobUser user) { var usergroups = Context.Group_User.Where(x => x.UserId == user.Id).ToList(); var groups = Context.Groups.Where(x => usergroups.FirstOrDefault(y => y.GroupId == x.Id) != null).ToList(); return(groups); }
public static void PutUserInGroup(DatabaseModels.Group group, NoobUser user) { var gu = Context.Group_User.FirstOrDefault(x => x.GroupId == group.Id && x.UserId == user.Id); if (gu == null) { Context.Group_User.Add(new Group_User { Id = Context.Group_User.Count() + 1, GroupId = group.Id, UserId = user.Id }); } Submit(); }
private static NoobUser SaveNewUser(User user, ChatId chatId = null) { var table = Context.User; var tempUser = new NoobUser { Id = user.Id, ChatId = chatId?.Identifier ?? 0, Name = string.IsNullOrWhiteSpace(user.Username) ? user.FirstName : user.Username, }; table.Add(tempUser); return(tempUser); }