Exemple #1
0
        public Dictionary <string, VoteUser> GetVoteUserDic()
        {
            string sql = "select * from t_acive_voteuser where LENGTH(bNo) = 7 and isVote = 1 order by bNo ASC";
            Dictionary <string, VoteUser> Dic = new Dictionary <string, VoteUser>();

            try
            {
                using (DataTable dt = helper.GetDataTable(sql))
                {
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        foreach (DataRow r in dt.Rows)
                        {
                            VoteUser u = new VoteUser()
                            {
                                addOn    = Convert.ToDateTime(r["addOn"]),
                                bNo      = r["bNo"].ToString(),
                                Contact  = r["contact"].ToString(),
                                Img_one  = r["Img_one"].ToString(),
                                Img_home = r["Img_home"].ToString(),
                                Mobile   = r["mobile"].ToString(),
                                openId   = r["openid"].ToString(),
                                uid      = Convert.ToInt32(r["uid"])
                            };
                            if (!Dic.ContainsKey(u.bNo))
                            {
                                Dic.Add(u.bNo, u);
                            }
                        }
                    }
                }
            }
            catch { }
            return(Dic);
        }
Exemple #2
0
        public List <VoteUser> GetUser(string sql, string sql_c, out int UCount)
        {
            int Count = 0;

            try
            {
                Count = Convert.ToInt32(helper.GetOne(sql_c));
            }
            catch
            {
                Count = 0;
            }
            List <VoteUser> lu = new List <VoteUser>();

            try
            {
                using (DataTable dt = helper.GetDataTable(sql))
                {
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        foreach (DataRow r in dt.Rows)
                        {
                            VoteUser u = new VoteUser()
                            {
                                addOn    = Convert.ToDateTime(r["addOn"]),
                                bNo      = r["bNo"].ToString(),
                                Contact  = r["contact"].ToString(),
                                Img_one  = r["Img_one"].ToString(),
                                Img_home = r["Img_home"].ToString(),
                                Mobile   = r["mobile"].ToString(),
                                openId   = r["openid"].ToString(),
                                uid      = Convert.ToInt32(r["uid"])
                            };
                            lu.Add(u);
                        }
                    }
                }
            }
            catch { }
            UCount = Count;
            return(lu);
        }
Exemple #3
0
        public async Task VoteAsync(int userAccId, string userId, bool isUpVote)
        {
            var vote = this.votesRepository.All()
                       .FirstOrDefault(x => x.UserAccId == userAccId && x.UserId == userId);

            if (vote != null)
            {
                vote.Type = isUpVote ? VoteType.UpVote : VoteType.DownVote;
            }
            else
            {
                vote = new VoteUser
                {
                    UserAccId = userAccId,
                    UserId    = userId,
                    Type      = isUpVote ? VoteType.UpVote : VoteType.DownVote,
                };

                await this.votesRepository.AddAsync(vote);
            }

            await this.votesRepository.SaveChangesAsync();
        }
Exemple #4
0
 public async Task <long> AddVote(VoteUser voteUser)
 {
     return(await _voteUserRepository.Create(voteUser));
 }