Exemple #1
0
        //[ApiExplorerSettings(IgnoreApi = true)]
        public UsersListResponse GetUsers(string fromDate, string toDate, string searchTerm, int userGroupId = 0, int pageSize = 25, int pageIndex = 1)
        {
            UsersListResponse retObj = new UsersListResponse(pageSize < 1 ? 1 : pageSize, pageIndex < 1 ? 1 : pageIndex);

            try
            {
                // set default date range
                DateTime fromDateTime = DateTime.Now.AddMonths(-3), toDateTime = DateTime.Now;

                try { toDateTime = Convert.ToDateTime(toDate); }
                catch { toDateTime = DateTime.Now; }

                try { fromDateTime = Convert.ToDateTime(fromDate); }
                catch { fromDateTime = DateTime.Now.AddMonths(-3); }

                int orderByColIndex = 5;
                Utility.EnumHelper.DBSortingOrder enSortingOrder = Utility.EnumHelper.DBSortingOrder.Desc;

                int usersCount;
                var userList = UserDetailsFacade.GetUsers(DateTime.Parse(fromDateTime.ToShortDateString()), DateTime.Parse(toDateTime.ToShortDateString()), searchTerm,
                                                          orderByColIndex, enSortingOrder, userGroupId, ((retObj.PageIndex * retObj.PageSize) - retObj.PageSize), retObj.PageSize, out usersCount);

                retObj.UserList         = userList;
                retObj.TotalRecordCount = usersCount;
            }
            catch (Exception exc)
            {
                log.Error(exc);
            }

            return(retObj);
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fromDate"></param>
        /// <param name="toDate"></param>
        /// <param name="searchTerm"></param>
        /// <param name="orderByColIndex"></param>
        /// <param name="sortingOrder"></param>
        /// <param name="userGroupId"></param>
        /// <param name="startRowIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="usersCount"></param>
        /// <returns></returns>
        public static List <ServiceEntities.ResponseEntities.UserDTO> GetUsers(DateTime fromDate, DateTime toDate, string searchTerm,
                                                                               int orderByColIndex, Utility.EnumHelper.DBSortingOrder sortingOrder, int userGroupId, int startRowIndex, int pageSize, out int usersCount)
        {
            List <ServiceEntities.ResponseEntities.UserDTO> retObj = new List <ServiceEntities.ResponseEntities.UserDTO>();

            usersCount = 0;

            try
            {
                DataSet ds = new UserDB(ConfigurationHelper.GPD_Connection).GetUsers(fromDate, toDate, searchTerm,
                                                                                     orderByColIndex, sortingOrder.ToString(), userGroupId, startRowIndex, pageSize);

                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        retObj.Add(new ServiceEntities.ResponseEntities.UserDTO()
                        {
                            UserId    = int.Parse(dr["user_id"].ToString()),
                            FirstName = dr["first_name"].ToString(),
                            LastName  = dr["last_name"].ToString(),
                            Email     = dr["email"].ToString(),
                            FirmName  = DBNull.Value.Equals(dr["firmName"]) ? "" : dr["firmName"].ToString(),
                            IsActive  = Convert.ToBoolean(dr["active"]),
                            CreatedOn = ((DateTime)dr["CREATE_DATE"]).ToString("o"),
                        });
                    }
                }

                if (ds != null && ds.Tables.Count > 1 && ds.Tables[1].Rows.Count == 1)
                {
                    int.TryParse(ds.Tables[1].Rows[0][0].ToString(), out usersCount);
                }
            }
            catch (Exception ex)
            {
                log.Error("Unable to get users for search term: " + searchTerm, ex);
            }

            return(retObj);
        }