public static bool AddShouter(this ShoutGroup shoutGroup, Shouter newShouter) { if (shoutGroup == null || newShouter == null) { return(false); } var appSettings = new AppSettings(); var availableGroups = appSettings.AvailableGroups; var group = availableGroups.SingleOrDefault(g => g.GroupId == shoutGroup.GroupId); if (group != null) { var shouters = @group.Shouters; shouters.Add(newShouter); } else { return(false); } appSettings.AvailableGroups = availableGroups; return(true); }
public static bool AddGroup(this ShoutGroup newGroup) { if (newGroup == null) { return(false); } var appSettings = new AppSettings(); if (appSettings.AvailableGroups == null) { appSettings.AvailableGroups = new List <ShoutGroup>(); } var availableGroups = appSettings.AvailableGroups; var thisUser = new Shouter { Name = DefaultShoutName, TimesShouted = 0 }; newGroup.Shouters = new List <Shouter> { thisUser }; newGroup.DateCreated = System.DateTime.Now; newGroup.CurrentShouterName = thisUser.Name; newGroup.GroupId = Guid.NewGuid().ToString(); availableGroups.Add(newGroup); appSettings.AvailableGroups = availableGroups; return(true); }