Exemplo n.º 1
0
        public async Task <IActionResult> CreateDivisionAsync(ClanId clanId, CreateDivisionRequest request)
        {
            var userId = HttpContext.GetUserId();

            var clan = await _clanService.FindClanAsync(clanId);

            if (clan == null)
            {
                return(this.NotFound("Clan does not exist."));
            }

            var result = await _clanService.CreateDivisionAsync(
                clan,
                userId,
                request.Name,
                request.Description);

            if (result.IsValid)
            {
                return(this.Ok("Division created."));
            }

            result.AddToModelState(ModelState);

            return(this.BadRequest(new ValidationProblemDetails(ModelState)));
        }