Exemplo n.º 1
0
        public async Task <IActionResult> Register([FromBody] Club entity)
        {
            User user = new User {
                Role     = "Club",
                UserName = entity.Email,
            };

            try {
                var result = await userManager.CreateAsync(user, entity.Password);

                if (result.Succeeded)
                {
                    bool resultForClubCreate = _clubLogic.Create(entity);
                    if (resultForClubCreate)
                    {
                        return(Ok());
                    }
                    else
                    {
                        await userManager.DeleteAsync(user);

                        return(StatusCode(500, "Failed"));
                    }
                }
                else
                {
                    return(StatusCode(500, "Failed"));
                }
            }
            catch (Exception) {
                return(StatusCode(500, "Failed"));
            }
        }