示例#1
0
        public IActionResult GetBuildings([FromQuery] int offset = 0, [FromQuery] int limit = 10, [FromQuery] string name = "", [FromQuery] string city = "")
        {
            var buildings = _manager.Buildings().Where(b => b.Name.IndexOf(name, StringComparison.CurrentCultureIgnoreCase) != -1 && b.Address.City.IndexOf(city, StringComparison.CurrentCultureIgnoreCase) != -1).Skip(offset).Take(limit);

            var buildingsMapped = _mapper.Map <IEnumerable <BuildingDTO> >(buildings).Select(b => new HALResponse(b).AddLinks(b.GetLinks()));

            return(Ok(new HALResponse(null).AddLinks(new[] {
                new Link("self", "/api/buildings", null, "GET")
            }).AddEmbeddedCollection("buildings", buildingsMapped)));
        }
示例#2
0
        public ViewResult Index(string sortOrder, string currentFilter, string searchString, int?page)
        {
            ViewBag.CurrentSort  = sortOrder;
            ViewBag.NameSortParm = string.IsNullOrEmpty(sortOrder) ? "name_desc" : "";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;

            var buildings = _buildingManager.Buildings();

            if (!string.IsNullOrEmpty(searchString))
            {
                buildings = buildings.Where(s => s.Name.ToLower().Contains(searchString.ToLower()));
            }


            switch (sortOrder)
            {
            case "name_desc":
                buildings = buildings.OrderByDescending(b => b.Name).ToList();
                break;

            default:
                buildings = buildings.OrderBy(b => b.Name).ToList();
                break;
            }

            const int pageSize   = 10;
            var       pageNumber = (page ?? 1);

            return(View(buildings.AsQueryable().ToPagedList(pageNumber, pageSize)));
        }
示例#3
0
        public ViewResult AddHall()
        {
            var buildings    = _buildingManager.Buildings();
            var openingHours = new List <OpeningHours>
            {
                new OpeningHours()
                {
                    Day = "Maandag"
                },
                new OpeningHours()
                {
                    Day = "Dinsdag"
                },
                new OpeningHours()
                {
                    Day = "Woensdag"
                },
                new OpeningHours()
                {
                    Day = "Donderdag"
                },
                new OpeningHours()
                {
                    Day = "Vrijdag"
                },
                new OpeningHours()
                {
                    Day = "Zaterdag"
                },
                new OpeningHours()
                {
                    Day = "Zondag"
                }
            };

            var hallOpeningHoursVM = new HallOpeningHoursVM {
                Buildings    = buildings.ToList(),
                OpeningHours = openingHours
            };

            return(View(hallOpeningHoursVM));
        }