/// <summary>
 /// Gets all members (clans) from the database async and filters members by first (Ime) or last name (Prezime).
 /// </summary>
 /// <param name="filter"></param>
 /// <returns>The members.</returns>
 public virtual async Task<List<IClan>> GetAsync(ClanFilter filter = null)
 {
     try
     {           
         if (filter != null)
         {
             return Mapper.Map<List<IClan>>(
                 await Repository.GetWhere<Clan>()
                 .OrderBy(k => k.Prezime)
                 .Skip((filter.PageNumber - 1) * filter.PageSize)
                 .Take(filter.PageSize)
                 .ToListAsync());
         }
         else
         {
             return Mapper.Map<List<IClan>>(
                 await Repository.GetWhere<Clan>()
                 .ToListAsync());
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        /// <summary>
        /// Gets members (clans) from the database async and filters members by first (Ime) or last name (Prezime).
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public virtual async Task<List<IClan>> GetRangeAsync(ClanFilter filter = null)
        {
            try
            {
                if (filter != null)
                {
                    return Mapper.Map<List<IClan>>(
                        await Repository.GetWhere<Clan>()
                        .OrderBy(c => c.Prezime)
                        .Where(c => c.Prezime.ToUpper()
                            .Contains(filter.SearchString.ToUpper())
                            || c.Ime.ToUpper()
                            .Contains(filter.SearchString.ToUpper()))
                        .Skip((filter.PageNumber - 1) * filter.PageSize)
                        .Take(filter.PageSize)
                        .ToListAsync());
                }

                return Mapper.Map<List<IClan>>(
                    await Repository.GetWhere<Clan>()
                    .ToListAsync());
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Gets members (clans) from the database async and filters members by first (Ime) or last name (Prezime).
 /// </summary>
 /// <param name="filter"></param>
 /// <returns></returns>
 public virtual Task<List<IClan>> GetRangeAsync(ClanFilter filter = null)
 {
     try
     {
         return Repository.GetRangeAsync(filter);
     }
     catch (Exception e)
     {
         throw e;
     }
 }