Exemple #1
0
        /// <summary>
        /// Get All User in WS_USER
        /// </summary>
        /// <returns>list ws_user</returns>
        public List <UserBasicInfoDTO> GetAllUser()
        {
            var listUser = new List <UserBasicInfoDTO>();

            try
            {
                List <int> userIdList;
                using (var db = new Ws_DataContext())
                {
                    userIdList = db.Ws_User.Select(x => x.UserID).ToList();
                }

                using (var db = new UserDAL())
                {
                    foreach (int userId in userIdList)
                    {
                        UserBasicInfoDTO userBasic = db.GetFullInforOfUserAsBasicUser(userId);
                        listUser.Add(userBasic);
                    }
                }
            }
            catch (Exception)
            {
                //throw;
            }

            return(listUser);
        }
Exemple #2
0
        /// <summary>
        /// Get top user who create most thread
        /// </summary>
        /// <param name="top"></param>
        /// <returns></returns>
        public List <UserBasicInfoDTO> GetTopNumberThreadCreator(int top)
        {
            List <UserBasicInfoDTO> topThreadCreator = new List <UserBasicInfoDTO>();

            try
            {
                List <UserBasicInfoDTO> listUser = new List <UserBasicInfoDTO>();


                // lay ra nhung userid co trong bang Thread
                List <int> listUserIdInDonation;

                using (var db = new Ws_DataContext())
                {
                    var listUserId = db.Threads.Select(x => x.UserId).Distinct();
                    listUserIdInDonation = listUserId.ToList();
                }

                // Lay thong tin cua nhung user ma co id trong Donation
                foreach (int userId in listUserIdInDonation)
                {
                    UserBasicInfoDTO userBasic;

                    using (var db = new UserDAL())
                    {
                        userBasic = db.GetFullInforOfUserAsBasicUser(userId);
                    }

                    listUser.Add(userBasic);
                }

                // Lay top 10 user donate nhieu nhat
                topThreadCreator = listUser.OrderByDescending(x => x.NumberOfPost).Take(top).ToList();
            }
            catch (Exception)
            {
                //throw;
            }
            return(topThreadCreator);
        }
        public OrganizationBasicInfo GetFullOrganizationBasicInformation(int orgId)
        {
            OrganizationBasicInfo organizationBasic = new OrganizationBasicInfo();

            try
            {
                Organization org = GetOrganizationById(orgId);

                organizationBasic.OrganizationId = orgId;
                if (org != null)
                {
                    organizationBasic.OrganizationName = org.OrganizationName;
                    organizationBasic.Introduction     = org.Introduction;
                    organizationBasic.LogoUrl          = org.LogoUrl;
                    organizationBasic.Phone            = org.Phone;
                    organizationBasic.Email            = org.Email;
                    organizationBasic.Address          = org.Address;
                    organizationBasic.IsActive         = org.IsActive;
                    organizationBasic.IsVerify         = org.IsVerify;
                    organizationBasic.CreatedDate      = org.CreatedDate.ToString("H:mm:ss dd/MM/yy");
                    organizationBasic.Point            = org.Point;
                    using (var db = new Ws_DataContext())
                    {
                        organizationBasic.CreatorName   = db.Organizations.Where(x => x.OrganizationId == orgId).SingleOrDefault().Ws_User.UserName;
                        organizationBasic.NumberOfEvent = db.Events.Where(x => x.CreatorID == organizationBasic.OrganizationId).Count();
                    }

                    WsRanking  ranking = new WsRanking();
                    RankingDTO rank    = ranking.RankingWithPoint(org.Point);
                    if (rank.CurrentRank == 0)
                    {
                        organizationBasic.CurrentRank = "Mới";
                    }
                    else if (rank.CurrentRank == 200)
                    {
                        organizationBasic.CurrentRank = "Đồng";
                    }
                    else if (rank.CurrentRank == 500)
                    {
                        organizationBasic.CurrentRank = "Bạc";
                    }
                    else if (rank.CurrentRank == 2000)
                    {
                        organizationBasic.CurrentRank = "Vàng";
                    }
                    else if (rank.CurrentRank == 5000)
                    {
                        organizationBasic.CurrentRank = "Bạch Kim";
                    }
                    else if (rank.CurrentRank == 10000)
                    {
                        organizationBasic.CurrentRank = "Kim Cương";
                    }
                    //get creator
                    using (var db = new UserDAL())
                    {
                        organizationBasic.Creator = db.GetFullInforOfUserAsBasicUser(orgId);
                    }
                }
            }
            catch (Exception)
            {
                //throw;
            }

            return(organizationBasic);
        }