コード例 #1
0
        public async Task Init()
        {
            if (GradoviList.Count == 0)//u prvom slucaju odnosno kada nista nije odabrano...ako je nesto odabrano ovo preskacemo
            {
                var listgrad = await _apiServiceGradovi.Get <IEnumerable <Grad> >(null);

                foreach (var grad in listgrad)
                {
                    GradoviList.Add(grad);
                }
            }
            if (SelectedGrad != null)//dolazimo ovdje kada korisnik odabere nesto u dropdown listi
            {
                StadioniSearchRequest searchRequest = new StadioniSearchRequest
                {
                    GradID = SelectedGrad.GradID//uzimamo id i saljemo na api
                };
                var list = await _apiServiceStadioni.Get <IEnumerable <Stadion> >(searchRequest);

                StadioniList.Clear();
                foreach (var stadion in list)
                {
                    StadioniList.Add(stadion);
                }
            }
        }
コード例 #2
0
        public override List <Stadion> Get(StadioniSearchRequest search)
        {
            var q = _context.Set <Database.Stadioni>().AsQueryable();

            if (!string.IsNullOrWhiteSpace(search?.Naziv) && search?.GradID.HasValue == true)
            {
                q = q.Where(s => s.Naziv.Equals(search.Naziv) && s.GradID == search.GradID);
            }
            else
            {
                if (search?.DrzavaID.HasValue == true)
                {
                    q = q.Include(s => s.Grad).Where(s => s.Grad.DrzavaID == search.DrzavaID);
                }
                if (!string.IsNullOrWhiteSpace(search?.Naziv))
                {
                    q = q.Where(s => s.Naziv.StartsWith(search.Naziv));
                }
                if (search?.GradID.HasValue == true)
                {
                    q = q.Where(s => (s.GradID == search.GradID));
                }
            }
            var list = q.ToList();

            return(_mapper.Map <List <Stadion> >(list));
        }