コード例 #1
0
ファイル: VehiclesController.cs プロジェクト: sourvinos/vega
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        public async Task <List <Students> > getStudents(FilterResource f)
        {
            var t = db.Students.AsQueryable();

            t.Where(a => a.StudentId == f.StudId);
            return(await t.ToListAsync());
        }
コード例 #6
0
        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"));
            }
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        public async Task <IActionResult> FilteredVehicles(FilterResource filterResource)
        {
            var filter = mapper.Map <FilterResource, Filter>(filterResource);

            var response = await this.vehicleRepository.GetVehicles(filter);

            return(Ok(response));
        }
コード例 #9
0
        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));
        }
コード例 #10
0
 public void SetUp()
 {
     SetupCandidateResorces();
     SetupCandidates();
     MockRepository();
     MockUnitOfWork();
     SetupMapper();
     SetupService();
     _filterResource = new FilterResource()
     {
         SkillId = 1
     };
 }
コード例 #11
0
 public void SetUp()
 {
     SetupCandidateResorces();
     _service = new Mock <ICandidateService>();
     MockGetAllCadnidatesAsync();
     MockGetCandidateAsync();
     MockAddCandidateAsync();
     MockUpdateCandidateAsync();
     MockDeleteSkillAsync();
     _controller     = new CandidatesController(_service.Object);
     _filterResource = new FilterResource()
     {
         SkillId = 1
     };
 }
コード例 #12
0
        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));
        }
コード例 #13
0
        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));
        }
コード例 #14
0
        public async Task <IActionResult> GetCandidatesAsync(FilterResource filterResource)
        {
            var candidates = await _candidateService.GetAllCandidatesAsync(filterResource);

            return(Ok(candidates));
        }
コード例 #15
0
        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));
        }