protected void AcceptPoll(object sender, EventArgs e) { int wvrId = int.Parse(wvrIdBox.Text); var songs = new List <SongInPollContract>(); foreach (var songRow in songList.Text.Split('\n')) { var stripped = StripHTML(songRow); stripped = stripped.Replace("\r", ""); var parts = stripped.Split('|'); if (parts.Length < 3) { continue; } int orderNum = int.Parse(parts[0]); var name = parts[1]; var nicoId = parts[2]; songs.Add(new SongInPollContract { SortIndex = orderNum, Name = name, NicoId = nicoId }); } var pollContract = new WVRPollContract { Name = pollNameBox.Text, Songs = songs.ToArray(), WVRId = wvrId }; Services.Polls.CreateWVRPoll(pollContract); Response.Redirect("Default.aspx?lastAction=pollCreated"); }
public void CreateWVRPoll(WVRPollContract contract) { HandleTransaction(session => { var poll = new WVRPoll(contract); foreach (var songContract in contract.Songs) { var c = songContract; var song = session.Linq <Song>().FirstOrDefault(s => s.NicoId == c.NicoId); if (song == null) { song = new Song { Name = songContract.Name, NicoId = songContract.NicoId }; session.Save(song); } poll.AddSong(song, songContract.SortIndex); session.Save(poll); } }); }
public WVRPoll(WVRPollContract contract) : base(contract) { WVRId = contract.WVRId; EndTime = DateTime.Now.AddDays(7); }