public async Task <QueryResultResource <VehicleResource> > Get(FilterResource filterResource) { var filter = mapper.Map <FilterResource, Filter>(filterResource); var queryResult = await vehicleRepository.GetVehicles(filter); return(mapper.Map <QueryResult <Vehicle>, QueryResultResource <VehicleResource> >(queryResult)); }
public async Task <IEnumerable <VehicleResource> > GetVehicles([FromQuery] FilterResource filterResource) { var filter = _mapper.Map <FilterResource, Filter>(filterResource); var vehicles = await _vehicleRepository.GetVehicles(filter); return(_mapper.Map <IEnumerable <Vehicle>, IEnumerable <VehicleResource> >(vehicles)); }
public IEnumerable <ProductResource> GetProducts(FilterResource filterResource) { Filter filter = mapper.Map <FilterResource, Filter>(filterResource); var products = productRepository.GetAll(filter).ToList(); return(mapper.Map <List <Product>, List <ProductResource> >(products)); }
public async Task <IEnumerable <VehicalResource> > GetVehicals(FilterResource filter) { var mfilter = mapper.Map <FilterResource, Filter>(filter); var vehicals = await vehicalRepository.GetVehicles(mfilter); return(mapper.Map <IEnumerable <Vehical>, IEnumerable <VehicalResource> >(vehicals)); }
public async Task <List <Students> > getStudents(FilterResource f) { var t = db.Students.AsQueryable(); t.Where(a => a.StudentId == f.StudId); return(await t.ToListAsync()); }
public async Task <IActionResult> GetPagedEmployee([FromBody] FilterResource filterResource) { try { //var filterResource = JsonConvert.DeserializeObject<FilterResource>(filterData); var result = new QueryResult <EmployeeDto>(); var filter = _mapper.Map <FilterResource, Filter>(filterResource); var queryResult = await _employeeService.GetAllPagedAsync(filter); result = _mapper.Map <QueryResult <Employee>, QueryResult <EmployeeDto> >(queryResult); Func <string, string, string> FullName = delegate(string firstName, string lastName) { return(firstName + " " + lastName); }; result.Items.ToList().ForEach(p => p.FullName = FullName(p.FirstName, p.LastName)); return(Json(new { data = result.Items, count = result.TotalItems })); } catch (Exception ex) { Console.WriteLine(ex.Message); return(StatusCode((int)HttpStatusCode.InternalServerError, "Error while retriving employees")); } }
public async Task <IEnumerable <VehicleResource> > GetVehicles(FilterResource filterRecource) { var filter = mapper.Map <FilterResource, Filter>(filterRecource); var vehicles = await this.repository.GetVehicles(filter); return(this.mapper.Map <IEnumerable <Vehicle>, IEnumerable <VehicleResource> >(vehicles)); }
public async Task <IActionResult> FilteredVehicles(FilterResource filterResource) { var filter = mapper.Map <FilterResource, Filter>(filterResource); var response = await this.vehicleRepository.GetVehicles(filter); return(Ok(response)); }
public async Task <IActionResult> Get([FromQuery] FilterResource filterResource) { var filter = mapper.Map <FilterResource, Filter>(filterResource); var games = await gameRepository.Get(filter); var result = mapper.Map <IEnumerable <Game>, IEnumerable <GameResource> >(games); return(Ok(result)); }
public void SetUp() { SetupCandidateResorces(); SetupCandidates(); MockRepository(); MockUnitOfWork(); SetupMapper(); SetupService(); _filterResource = new FilterResource() { SkillId = 1 }; }
public void SetUp() { SetupCandidateResorces(); _service = new Mock <ICandidateService>(); MockGetAllCadnidatesAsync(); MockGetCandidateAsync(); MockAddCandidateAsync(); MockUpdateCandidateAsync(); MockDeleteSkillAsync(); _controller = new CandidatesController(_service.Object); _filterResource = new FilterResource() { SkillId = 1 }; }
public async Task <IEnumerable <PhotoResource> > GetPhotos([FromQuery] FilterResource filter) { IEnumerable <Photo> photos; if (filter.PhotoName != null) { photos = await photoRepo.Find(p => p.Name.Contains(filter.PhotoName)); } else { photos = await photoRepo.GetAll(); } return(mapper.Map <IEnumerable <Photo>, IEnumerable <PhotoResource> >(photos)); }
public async Task <IEnumerable <BookstoreResource> > GetBookStore(BookstoreResource bookstoreResource, FilterResource filterResource) { var filter = mapper.Map <FilterResource, Filter>(filterResource); var query = context.Bookstores.AsQueryable(); if (filter.Id.HasValue) { query = query.Where(b => b.Id == filter.Id.Value); } //start code for sorting var columnsMap = new Dictionary <string, Expression <Func <Bookstore, object> > >() { ["name"] = b => b.Name, ["title"] = b => b.Title, ["authorName"] = b => b.AuthorName, ["publisherName"] = b => b.PublisherName, }; query = query.ApplyOrdering(filter, columnsMap); //end code for sorting var bookstore = await query.ToListAsync(); return(mapper.Map <IEnumerable <Bookstore>, IEnumerable <BookstoreResource> >(bookstore)); }
public async Task <IActionResult> GetCandidatesAsync(FilterResource filterResource) { var candidates = await _candidateService.GetAllCandidatesAsync(filterResource); return(Ok(candidates)); }
public async Task <QueryResultResource <CandidateResource> > GetAllCandidatesAsync(FilterResource filterResource) { var candidates = await _repository.GetAllCandidatesAsync(_mapper.Map <FilterResource, Filter>(filterResource)); return(_mapper.Map <QueryResult <Candidate>, QueryResultResource <CandidateResource> >(candidates)); }