private async void BtnPretraga_Click(object sender, EventArgs e) { AutoriSearchRequest request = new AutoriSearchRequest() { ImePrezime = txtPretraga.Text }; var source = await autoriService.Get <List <Biblioteka_Model.Autori> >(request); dgvAutori.AutoGenerateColumns = false; dgvAutori.DataSource = source; }
private async Task UcitajAutore() { var request = new AutoriSearchRequest { Ime = ImeTextBox.Text, Prezime = PrezimeTextBox.Text }; var autori = await _autoriService.Get <List <Model.Autori> >(request); AutoriDGV.DataSource = autori; }
public List <Biblioteka_Model.Autori> Get(AutoriSearchRequest request) { var list = _context.Autori.AsQueryable(); if (request.ImePrezime == null) { return(_mapper.Map <List <Biblioteka_Model.Autori> >(list)); } else { list = list.Where(x => x.Ime.StartsWith(request.ImePrezime) || x.Prezime.StartsWith(request.ImePrezime)); return(_mapper.Map <List <Biblioteka_Model.Autori> >(list)); } }
public override List <Model.Autori> Get(AutoriSearchRequest search) { var query = _context.Autori.AsQueryable(); if (!string.IsNullOrWhiteSpace(search?.Ime)) { query = query.Where(x => x.Ime != null && x.Ime.StartsWith(search.Ime, StringComparison.CurrentCultureIgnoreCase)); } if (!string.IsNullOrWhiteSpace(search?.Prezime)) { query = query.Where(x => x.Prezime != null && x.Prezime.StartsWith(search.Prezime, StringComparison.CurrentCultureIgnoreCase)); } if (!string.IsNullOrWhiteSpace(search?.Pseudonim)) { query = query.Where(x => x.Pseudonim != null && x.Pseudonim.StartsWith(search.Pseudonim, StringComparison.CurrentCultureIgnoreCase)); } var list = query.ToList(); return(_mapper.Map <List <Model.Autori> >(list)); }
public List <Biblioteka_Model.Autori> Get([FromQuery] AutoriSearchRequest request) { return(_service.Get(request)); }