Beispiel #1
0
        public async Task <ActionResult <string> > RegisterCoach([FromBody] CoachRegisterModel coachRegisterModel)
        {
            string coachId;

            try
            {
                coachId = await _coachService.RegisterCoachAsync(coachRegisterModel);
            }
            catch (Exception e)
            {
                return(BadRequest($"Can't regster the coach: {e.Message}"));
            }

            return(Ok(coachId));
        }
Beispiel #2
0
        private async Task <string> RegisterToDatabase(CoachRegisterModel coachRegisterModel)
        {
            Coach databaseCoach = new Coach()
            {
                UserId          = coachRegisterModel.UserId,
                CandidatingDate = DateTime.Now,
                Status          = CoachStatus.Candidating,
                Step            = CoachSteps.Preselected,

                Situation   = coachRegisterModel.Situation,
                Description = coachRegisterModel.Description
            };

            await _coachs.InsertOneAsync(databaseCoach);

            return(databaseCoach.Id);
        }
Beispiel #3
0
        // Register the coach
        public async Task <string> RegisterCoachAsync(CoachRegisterModel coachRegisterModel)
        {
            if (!UserExist(coachRegisterModel.UserId))
            {
                throw new Exception("The user doesn't existe");
            }
            if (CoachExist(coachRegisterModel.UserId))
            {
                throw new Exception("The coach already exists");
            }

            string coachId = await RegisterToDatabase(coachRegisterModel);

            await _formsService.RegisterFormToDatabseAsync(coachRegisterModel.UserId, coachRegisterModel.FormQAs);

            return(coachId);
        }