예제 #1
0
        public IActionResult Post(StadiumModel Stadium)
        {
            bool Stadiumexist = _StadiumServices.GetStadiumsList().Any(x => x.Value.StadiumName == Stadium.StadiumName);

            if (!Stadiumexist)
            {
                using (var scope = new TransactionScope())
                {
                    _StadiumServices.AddStadium(Stadium);
                    scope.Complete();
                    return(CreatedAtAction(nameof(Get), new { id = Stadium.StadiumID }, Stadium));
                }
            }
            return(StatusCode(StatusCodes.Status500InternalServerError, new { message = "Stadium already exist" }));
        }
예제 #2
0
        public IActionResult StadiumCreated(Stadium Stadium)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError(string.Empty, "Something went wrong:");
                ViewBag.Stadiums = _clubService.GetAllClubs();
                return(View("CreateStadium"));
            }

            _logger.LogInformation("StadiumController- Model state VALID");

            _StadiumService.AddStadium(Stadium);

            _logger.LogInformation("StadiumController- Stadium succesfully created.");

            return(RedirectToAction("AllStadiums"));
        }
예제 #3
0
 public async Task <string> AddStadium(Stadium stadium)
 {
     return(await _service.AddStadium(stadium));
 }
예제 #4
0
        public async Task <IActionResult> Post([FromBody] Domain.Entities.Stadium stadium)
        {
            await _service.AddStadium(stadium);

            return(Ok());
        }