예제 #1
0
        public async Task <ActionResult <Studio> > CreateStudio(Studio studio)
        {
            try
            {
                if (studio == null)
                {
                    return(BadRequest());
                }
                var sEmail = await _studioRepository.GetStudioByEmail(studio.Email);

                if (sEmail != null)
                {
                    ModelState.AddModelError("Email", "Email existe déjà");
                    return(BadRequest(ModelState));
                }
                var createdStudio = await _studioRepository.AddStudio(studio);

                return(CreatedAtAction(nameof(GetStudio), new { id = createdStudio.Id }, createdStudio));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "Erreur execption non capturée de database, cela peut être une erreur de connexion"));
            }
        }