Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <User> Find(out int totalRecords, UserCriteria userCriteria = null, int currentRecordIndex = 0, int maxRecord = 0)
        {
            totalRecords = 0;
            List <User> resultList = null;
            IQueryable <ApplicationUser> rowList = _dbContext.Users;

            CriteriaTransformer.CompleteQuery(ref rowList, userCriteria);
            if (userCriteria == null || userCriteria.FieldSortList == null || userCriteria.FieldSortList.Count == 0)
            {
                rowList = rowList.OrderBy(u => u.UserName);
            }

            if (maxRecord > 0)
            {
                totalRecords = rowList.Count();
                rowList      = rowList.Skip(currentRecordIndex).Take(maxRecord);
            }

            if (rowList != null)
            {
                foreach (var applicationUserRow in rowList)
                {
                    if (resultList == null)
                    {
                        resultList = new List <User>();
                    }
                    resultList.Add(UserTransformer.ToBean(applicationUserRow));
                }
            }
            return(resultList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get data in database
        /// </summary>
        /// <param name="key">Primary Key</param>
        /// <returns>read data</returns>
        public User Get(UserKey key)
        {
            if (key == null || string.IsNullOrWhiteSpace(key.Id))
            {
                return(null);
            }

            User            user = null;
            ApplicationUser row  = _dbContext.Users.Where(m => m.Id == key.Id).FirstOrDefault();

            if (row != null)
            {
                user = UserTransformer.ToBean(row);
            }

            return(user);
        }