コード例 #1
0
        public IActionResult Get(int id)
        {
            if (id.Equals(0) || _sportAccess.GetSport(id) == null)
            {
                return(BadRequest());
            }
            var resource = new SportResource(_sportAccess.GetSport(id));
            var response = new HALResponse(resource).AddSelfLink(Request).AddLinks(
                new Link("sport", "/api/Sport/", null, "GET"));

            return(Ok(response));
        }
コード例 #2
0
        public IActionResult AddSportAttributeConfirmed(SportAttributesViewModel viewModel)
        {
            ViewBag.Title = "Sportmateriaal toevoegen";

            if (ModelState.ContainsKey("NewAttribute.Sport") && ModelState.ContainsKey("NewAttribute.Hall"))
            {
                ModelState["NewAttribute.Sport"].ValidationState = ModelValidationState.Valid;
                ModelState["NewAttribute.Hall"].ValidationState  = ModelValidationState.Valid;
            }

            if (!ModelState.IsValid)
            {
                viewModel.Sports = _sportAccess.GetSports();
                return(View(viewModel));
            }

            viewModel.NewAttribute.Hall  = _complexAccess.GetHall(viewModel.SportHallId);
            viewModel.NewAttribute.Sport = _sportAccess.GetSport(viewModel.SportId);
            _complexAccess.AddSportAttribute(viewModel.NewAttribute);

            return(RedirectToAction("SportAttribute", viewModel));
        }
コード例 #3
0
        public ViewResult UpdateSport(int id)
        {
            ViewBag.Title = "Sport wijzigen";

            return(View(_sportAccess.GetSport(id)));
        }