//[Authorize] public override async Task <EmptyReply> Delete(CountrySearchRequest request, ServerCallContext context) { //var currentUser = context.GetHttpContext().User; await _countryService.DeleteAsync(request.CountryId); return(new EmptyReply()); }
public List <Model.Country> Get(CountrySearchRequest request) { var query = _context.Country.AsQueryable(); if (!string.IsNullOrWhiteSpace(request?.Name)) { query = query.Where(x => x.Name.ToLower().Contains(request.Name.ToLower())); } var list = query.ToList(); return(_mapper.Map <List <Model.Country> >(list)); }
private async void SearchButton_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtBox_TransportSearch.Text)) { var request = new CountrySearchRequest { CountryName = txtBox_TransportSearch.Text }; var result = await _service.Get <List <CountryDTO> >(request); BindingSource source = new BindingSource(result, null); countryGrid.DataSource = source; countryGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; } }
public override async Task <EmptyReply> Delete(CountrySearchRequest request, ServerCallContext context) { var currentUser = context.GetHttpContext().User; try { await _countryService.DeleteAsync(request.CountryId); return(new EmptyReply()); } catch (Exception e) { throw new RpcException(Status.DefaultCancelled, e.Message); } }
public override async Task <CountryReply> GetById(CountrySearchRequest request, ServerCallContext context) { var currentUser = context.GetHttpContext().User; try { var country = await _countryService.GetByIdAsync(request.CountryId); return(_mapper.Map <CountryReply>(country)); } catch (Exception e) { throw new RpcException(Status.DefaultCancelled, e.Message); } }
public override async Task <CountryReply> GetById(CountrySearchRequest request, ServerCallContext context) { var currentUser = context.GetHttpContext().User; try { var country = await _countryService.GetByIdAsync(request.CountryId); return(_mapper.Map <CountryReply>(country)); } catch (Exception e) { var httpContext = context.GetHttpContext(); httpContext.Response.StatusCode = 500; // Required to fire Polly retry policy, else 200 will be returned throw new RpcException(Status.DefaultCancelled, e.Message); } }
public IList <Model.Country> GetAll(CountrySearchRequest request) { var query = _context.Country.AsQueryable(); if (!string.IsNullOrWhiteSpace(request?.Name)) { query = query.Where(x => x.Name.StartsWith(request.Name)); } //if (!string.IsNullOrWhiteSpace(request?.OtherProperty)) //{ // query = query.Where(x => x.Name.StartsWith(request.OtherProperty)); //} var list = query.ToList(); return(_mapper.Map <IList <Model.Country> >(list)); }
//[Authorize] public override async Task <CountryReply> GetById(CountrySearchRequest request, ServerCallContext context) { var country = await _countryService.GetByIdAsync(request.CountryId); return(_mapper.Map <CountryReply>(country)); }
public IList <Model.Country> GetAll([FromQuery] CountrySearchRequest request) { return(_service.GetAll(request)); }