Ejemplo n.º 1
0
        public Vote Vote(int id)
        {
            string Username = HttpContext.Current.Request["LOGON_USER"];

            if (!Restaurants.Any(i => i.ID == id))
            {
                throw new Exception("No restaurant exists with that id.");
            }
            Restaurant Restaurant = Restaurants.First(i => i.ID == id);
            var        Vote       = new Vote(Restaurant, Username);

            if (this.Votes.Any(i => i.Username == Username && i.Timestamp >= DateTime.Today))
            {
                throw new Exception("You cannot vote twice per day.");
            }
            Votes.Add(Vote);
            return(Vote);
        }