public FrontMyClub(Club club, string recentText) { this.Id = club.Id; ColorHandler ch = new ColorHandler(); this.recentText = recentText; clubColor = club.Color; Title = club.Title; founderId = club.FounderId; starNumber = club.GetRating(); }
/// Create a club; returns true if success, false if fails; fails if club name already in use or user is banned public async Task<bool> CreateClub(string title, string color, bool exclusive, List<string> tagList) { //check if banned (must get current instance of user account incase ban happend since login) User = await accountTable.LookupAsync(User.Id); if (DateTime.Compare(User.Banned, DateTime.Now) > 0) { return false; } Club club = new Club(User.CurrentCloudId, title, color, exclusive, User.Id); //check if the club name is in use var list = await clubTable.Where(item => item.Title.ToLower() == club.Title.ToLower() && item.CloudId==User.CurrentCloudId).ToListAsync(); if (list.Count > 0) { return false; } else { await clubTable.InsertAsync(club); //add tags to table based on title string[] titleTagList = title.Split(' '); foreach (string key in titleTagList) { Tag tag = new Tag(key.ToLower(), club.Id, club.CloudId); await tagTable.InsertAsync(tag); } //add tags to table based on tagList foreach (string key in tagList) { Tag tag = new Tag(key.ToLower(), club.Id,club.CloudId); await tagTable.InsertAsync(tag); } //add club founder to memberJunction //club size is initialized to one automatically MemberJunction memberJunction = new MemberJunction(User.Id, club.Id); await memberJuncTable.InsertAsync(memberJunction); //update user account User.NumClubsCreated++; User.NumClubsIn++; User.Points++; await accountTable.UpdateAsync(User); //make DBNotification DBNotification DBNotification = new DBNotification(User.Id, "join", "You created the club " + club.Title + "!"); await dbNotificationTable.InsertAsync(DBNotification); return true; } }