Esempio n. 1
0
        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");
        }
Esempio n. 2
0
        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);
                }
            });
        }
Esempio n. 3
0
 public WVRPoll(WVRPollContract contract)
     : base(contract)
 {
     WVRId   = contract.WVRId;
     EndTime = DateTime.Now.AddDays(7);
 }