Ejemplo n.º 1
0
        public async Task <IActionResult> CreateClub([FromForm] CreateClubModel createClubModel)
        {
            Club club = _clubsService.GetClubByName(createClubModel.Name);

            if (club != null)
            {
                return(BadRequest("Името е заето"));
            }

            await _clubsService.CreateClub(createClubModel);

            await _clubsService.SaveChangesAsync();

            return(Ok());
        }
Ejemplo n.º 2
0
 public async Task <IActionResult> CreateClub([FromBody] CreateClubDto club)
 {
     try
     {
         var email = User.Claims.SingleOrDefault(c => c.Type == "email")?.Value;
         if (string.IsNullOrEmpty(email))
         {
             return(BadRequest("Authorization failed."));
         }
         return(Ok(await _service.CreateClub(club, email)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }