Exemple #1
0
        public IActionResult CreateTeam([FromBody] NewTeamForm teamForm)
        {
            // Create a new Team Request body
            var team = teamForm.NewTeam;
            var res  = new BaseResponse();

            try
            {
                // Send the request to the Team Manager
                var createdTeam = manager.CreateTeam(teamForm.NewTeam);
                if (createdTeam)
                {
                    // Respond with a 200 + the team body
                    res.Code = 200;
                    res.HasBeenSuccessful = true;
                    return(Ok(res));
                }
                // Reponse with 401, something went wrong
                res.Code = 401;
                res.HasBeenSuccessful = false;
                return(Ok(res));
            }
            catch (Exception e)
            {
                // Reponse with 501, something went wrong internally
                res.Code = 501;
                res.HasBeenSuccessful = false;
                return(Ok(res));
            }
        }
Exemple #2
0
        public async Task <IActionResult> CreateTeamView(TeamModel model)
        {
            var currentUser = await userManager.GetUserAsync(User);

            model.OwnerID = currentUser.Id;
            teamManager.CreateTeam(model);
            TeamsView();
            return(Redirect("TeamsView"));
        }