예제 #1
0
        public ActionResult <PollInfo> GetNewestPoll()
        {
            var poll = pollDac.Get(it => it.IsClose == false);

            if (poll == null)
            {
                return(null);
            }
            var pollinfo = new PollInfo
            {
                Id       = poll.Id,
                ShopName = poll.ShopName,
                CreateAt = poll.CreateAt,
                CreateBy = poll.CreateBy,
                IsClose  = poll.IsClose,
                Menus    = poll.Menus,
                Unvoter  = new List <string>()
            };
            var accounts = accDac.List(it => true);

            pollinfo.Menus.ToList().ForEach((menu) =>
            {
                if (menu.Voter != null || menu.Voter.Count != 0)
                {
                    menu.Voter.ToList().ForEach((voter) =>
                    {
                        accounts = accounts.Where(acc => acc.Username != voter);
                    });
                }
            });

            foreach (var acc in accounts)
            {
                pollinfo.Unvoter.Add(acc.Username);
            }
            return(pollinfo);
        }