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" })); }
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")); }
public async Task <string> AddStadium(Stadium stadium) { return(await _service.AddStadium(stadium)); }
public async Task <IActionResult> Post([FromBody] Domain.Entities.Stadium stadium) { await _service.AddStadium(stadium); return(Ok()); }