public async Task <IActionResult> Create([FromBody] CreateLeagueCommand cmd) { var isValid = ModelState.IsValid; var dto = await _leagueService.CreateLeague(cmd); return(dto == null ? (IActionResult)BadRequest() : Created(new Uri("a"), dto)); }
public ActionResult Create(CreateLeagueViewModel model) { if (!ModelState.IsValid) { return(View(model)); } _leagueService.CreateLeague(model.SelectedCompetitionId, CurrentPlayerId, model.LeagueName); return(RedirectToAction("Index")); }
public string Execute(IReadOnlyList <string> args) { if (args.Count != 1) { throw new ArgumentException("A League has to has name"); } var name = args[0]; InputValidations.ValidateLength(InputValidations.MIN_NAME, InputValidations.MAX_NAME, name, $"A league's name must be between {InputValidations.MIN_NAME} and {InputValidations.MAX_NAME} characters"); var league = service.CreateLeague(name); return($"League {league.Name} has been created."); }
public IActionResult CreateLeague([FromBody] LeagueModelCreate leagueModelCreate) { try { int userId = int.Parse(User.Identity.Name); bool hasAccess = _leagueService.CheckLeagueAccess(userId, leagueModelCreate.OrganisationId); if (!hasAccess) { return(Forbid()); } _leagueService.CreateLeague(leagueModelCreate); // TODO CreatedAtRoute return(Ok()); } catch (Exception e) { return(StatusCode(500, e.Message)); } }