示例#1
0
        public ViewResult EditSportsHall(EditSportsHallFormViewModel viewModel, int SelectedProprietor)
        {
            SportsHall aHall = sportsHallRepository.Halls.FirstOrDefault(x => x.ID == viewModel.Hall.ID);

            Proprietor aProprietor = proprietorRepository.Proprietors.Where(x => x.ID == SelectedProprietor).FirstOrDefault();

            aHall.Proprietor  = aProprietor;
            aHall.Name        = viewModel.Hall.Name;
            aHall.Description = viewModel.Hall.Description;
            aHall.Phone       = viewModel.Hall.Phone;
            aHall.City        = viewModel.Hall.City;
            aHall.StreetName  = viewModel.Hall.StreetName;
            aHall.HouseNumber = viewModel.Hall.HouseNumber;
            aHall.Zip         = viewModel.Hall.Zip;

            if (ModelState.IsValid)
            {
                sportsHallRepository.EditSportsHall(aHall);
                return(View("SportsHallList", sportsHallRepository.Halls));
            }
            else
            {
                return(View("SportsHallList", sportsHallRepository.Halls));
            }
        }
示例#2
0
        public IActionResult Put(int id, [FromBody] SportsHall Hall)
        {
            if (Hall == null || id != Hall.ID)
            {
                return(BadRequest());
            }
            var hall = repository.Halls.SingleOrDefault(x => x.ID == id);

            if (hall == null)
            {
                return(NotFound());
            }
            repository.EditSportsHall(Hall);
            return(CreatedAtAction(nameof(Get),
                                   new { id = Hall.ID }, Hall));
        }