public async Task Init()
        {
            if (LigeList.Count == 0)//u prvom slucaju odnosno kada nista nije odabrano...ako je nesto odabrano ovo preskacemo
            {
                var ligalist = await _apiServiceLige.Get <IEnumerable <Liga> >(null);

                foreach (var liga in ligalist)
                {
                    LigeList.Add(liga);
                }
            }
            if (SelectedLiga != null)//dolazimo ovdje kada korisnik odabere nesto u dropdown listi
            {
                TimoviSearchRequest searchRequest = new TimoviSearchRequest
                {
                    LigaID = SelectedLiga.LigaID//uzimamo id i saljemo na api
                };
                var list = await _apiServiceTimovi.Get <IEnumerable <Tim> >(searchRequest);

                TimoviList.Clear();
                foreach (var tim in list)
                {
                    TimoviList.Add(tim);
                }
            }
        }
Beispiel #2
0
        private async void BtnPretrazi_Click(object sender, EventArgs e)
        {
            var search = new TimoviSearchRequest()
            {
                Naziv = txtPretraga.Text
            };
            var res = await _apiService.Get <dynamic>(search);

            dgvTribine.AutoGenerateColumns = false;
            dgvTribine.DataSource          = res;
        }
        public override List <Tim> Get(TimoviSearchRequest search)
        {
            var q = _context.Set <Database.Timovi>().AsQueryable();

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

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