Beispiel #1
0
        /// <summary>
        /// Get all lost person from red cross
        /// </summary>
        /// <param name="redCrossId"></param>
        /// <returns></returns>
        public async Task<IEnumerable<ILostPerson>> GetAllAsync(Guid redCrossId, GenericFilter filter)
        {
            try
            {
                if (filter != null)
                {
                    var lp = AutoMapper.Mapper.Map<IEnumerable<ILostPerson>>(await Repository.GetEverything<LostPersonEntity>()).OrderBy(l => l.LastName).ToList();

                    if (redCrossId != null)
                    {
                        lp = lp.Where(l => l.RedCrossId.Equals(redCrossId)).ToList();
                    }

                    var page = lp.ToPagedList(filter.pageNumber, filter.pageSize);
                    var lpPage = new StaticPagedList<ILostPerson>(page, page.GetMetaData());
                    return lpPage;
                }
                else
                {
                    return AutoMapper.Mapper.Map<IEnumerable<ILostPerson>>(await Repository.GetAllAsync<LostPersonEntity>(l => l.RedCrossId.Equals(redCrossId))).OrderBy(l => l.ReportDate).ToList();
                }

                //return AutoMapper.Mapper.Map<IEnumerable<ILostPerson>>(await Repository.GetAllAsync<LostPersonEntity>(l => l.RedCrossEntityId.Equals(redCrossId))).OrderBy(l => l.LastName); //Destination ILostPerson; Source: LostPersonEntity
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Get all
        /// </summary>
        /// <returns></returns>
        public async Task<IEnumerable<IRedCross>> GetAsync(GenericFilter filter)
        {
            
            try
            {
                if (filter != null)
                {
                    var rc = AutoMapper.Mapper.Map<IEnumerable<IRedCross>>(await Repository.GetEverything<RedCrossEntity>()).OrderBy(r => r.Name).ToList();

                    if (!string.IsNullOrWhiteSpace(filter.searchString))
                    {
                        rc = rc.Where(r =>
                            r.Name.ToLower().Contains(filter.searchString.ToLower()) ||
                            r.Country.ToLower().Contains(filter.searchString.ToLower())
                        ).ToList();
                    }

                    var page = rc.ToPagedList(filter.pageNumber, filter.pageSize);
                    var rcPage = new StaticPagedList<IRedCross>(page, page.GetMetaData());
                    return rcPage;
                }
                else
                {
                    return AutoMapper.Mapper.Map<IEnumerable<IRedCross>>(await Repository.GetEverything<RedCrossEntity>()).OrderBy(r => r.Name).ToList();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
 public virtual Task<IEnumerable<ILostPerson>> GetAllLostPersons(GenericFilter filter)
 {
     try
     {
         return lostRepository.GetEveryoneAsync(filter);
     }
     catch(Exception ex)
     {
         throw ex;
     }
 }
Beispiel #4
0
        /// <summary>
        /// Get all lost persons
        /// </summary>
        /// <returns>List of lost persons</returns>
        public async Task<IEnumerable<ILostPerson>> GetEveryoneAsync(GenericFilter filter)
        {
            try
            {
                if (filter != null)
                {
                    var lp = AutoMapper.Mapper.Map<IEnumerable<ILostPerson>>(await Repository.GetEverything<LostPersonEntity>()).OrderBy(l => l.LastName).ToList(); //Fetch all lost, order by last name, add to list

                    if (!string.IsNullOrWhiteSpace(filter.searchString))
                    {
                        //Filter entire list
                        lp = lp.Where(l => 
                            l.LastName.ToLower().Contains(filter.searchString.ToLower()) ||
                            l.FirstName.ToLower().Contains(filter.searchString.ToLower()) ||
                            l.LocationLastSeen.ToLower().Contains(filter.searchString.ToLower())
                        ).ToList();
                    }

                    //Page filtered data
                    var page = lp.ToPagedList(filter.pageNumber, filter.pageSize);
                    var lpPage = new StaticPagedList<ILostPerson>(page, page.GetMetaData());
                    return lpPage;
                }
                else
                {
                    return AutoMapper.Mapper.Map<IEnumerable<ILostPerson>>(await Repository.GetEverything<LostPersonEntity>()).OrderBy(l => l.LastName).ToList(); //Destination ILostPerson; Source: LostPersonEntity
                }

                
            }
            catch (Exception ex)
            {
                throw ex;
            }

                //return AutoMapper.Mapper.Map<IEnumerable<ILostPerson>>(await Repository.GetEverything<LostPersonEntity>()).OrderBy(l => l.LastName); //Destination ILostPerson; Source: LostPersonEntity
        }
Beispiel #5
0
 public Task<IEnumerable<IRedCross>> GetAllAsync(GenericFilter filter)
 {
     return Repository.GetAsync(filter);
 }
Beispiel #6
0
 public Task<IEnumerable<ILostPerson>> GetFromRedCross(Guid id, GenericFilter filter)
 {
     return lostRepository.GetAllAsync(id);
 }