Esempio n. 1
0
        public IActionResult Get()
        {
            var list   = houseRepository.GetAll();
            var result = mapper.Map <List <House>, List <HouseDto> >(list);

            return(Ok(list));
        }
Esempio n. 2
0
        public async Task <IActionResult> GetAll()
        {
            var lstHouse = await _houseRepository.GetAll();

            ViewBag.LstHouse = await ConvertAllHouseToList(lstHouse);

            return(View());
        }
        public IActionResult GetAllHouses()
        {
            var allHouseEntitys = _houseRepository.GetAll().ToList();

            var allHouseEntitysDto = allHouseEntitys.Select(x => Mapper.Map <HouseDto>(x));

            Response.Headers.Add("X-Pagination",
                                 JsonConvert.SerializeObject(new { totalCount = _houseRepository.Count() }));

            return(Ok(allHouseEntitysDto));
        }
Esempio n. 4
0
 public IActionResult Get()
 {
     try
     {
         return(Ok(_houseRepository.GetAll().Select(x => _houseMapper.MapToDto(x))));
     }
     catch (Exception exception)
     {
         //logg exception or do anything with it
         return(StatusCode((int)HttpStatusCode.InternalServerError));
     }
 }
        public IActionResult GetAll()
        {
            var  houses         = _houseRepository.GetAll();
            var  claimsIdentity = this.User.Identity as ClaimsIdentity;
            var  userId         = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
            bool succes         = Int32.TryParse(userId, out var ownerId);

            if (succes)
            {
                return(Ok(houses.Where(h => h.OwnerId == ownerId)));
            }
            return(Ok(houses));
        }
Esempio n. 6
0
        public async Task <IHttpActionResult> Get(int page = 1, int pageSize = MaxPageSize)
        {
            if (pageSize > MaxPageSize)
            {
                pageSize = MaxPageSize;
            }

            var paginationHeader = new
            {
                totalCount = _houseRepository.GetAll().Count
                             // Add more headers here if you want...
                             // Link to next and previous page etc.
                             // Also see OData-Options for this
            };

            List <HouseEntity> result = _houseRepository.GetAll()
                                        .Skip(pageSize * (page - 1))
                                        .Take(pageSize)
                                        .ToList();

            HttpContext.Current.Response.AppendHeader("X-Pagination", JsonConvert.SerializeObject(paginationHeader));

            return(Ok(result.Select(x => _houseMapper.MapToDto(x))));
        }
Esempio n. 7
0
        public HouseQuery(IHouseRepository houseRepository)
        {
            Field <HouseType>("house",
                              arguments:
                              new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id"
            }),
                              resolve: context =>
                              houseRepository.GetById(context.GetArgument <int>("id"))
                              );

            Field <ListGraphType <HouseType> >("houses",
                                               resolve: context =>
                                               houseRepository.GetAll());
        }
Esempio n. 8
0
 public IEnumerable <House> GetAllHouses()
 {
     return(m_houseRepository.GetAll());
 }
Esempio n. 9
0
 public IActionResult Get()
 {
     return(Ok(_houseRepository.GetAll().Select(x => _houseMapper.MapToDto(x))));
 }
Esempio n. 10
0
 public IActionResult Create()
 {
     ViewBag.Houses = houseRepository.GetAll();
     return(View());
 }
Esempio n. 11
0
        public async Task <IEnumerable <HouseModel> > GetHouses()
        {
            var houses = await _houseRepository.GetAll();

            return(houses.OrderBy(h => h.Name).Select(BusinessMapper.Map <HouseModel>));
        }
Esempio n. 12
0
 public async Task <ICollection <House> > GetAll()
 {
     return(await _houses.GetAll());
 }
Esempio n. 13
0
        public ActionResult <IEnumerable <House> > Get()
        {
            var types = repository.GetAll();

            return(types);
        }
 public IEnumerable <Stat> GetTopTenWithGarden()
 => GetTopTen(_repository
              .GetAll()
              .Where(h => h.HadGarden));
Esempio n. 15
0
        public IHttpActionResult Get()
        {
            List <HouseEntity> result = houseRepository.GetAll();

            return(Ok(result.Select(x => houseMapper.MapToDto(x))));
        }
Esempio n. 16
0
 public IEnumerable <CageModel> GetAll()
 {
     return(_houseRepository.GetAll().Select(x => new CageModel()));
 }