Exemple #1
0
        public ActionResult <AdminDto> SignUp(SignUpDto input)
        {
            if (input == null)
            {
                return(BadRequest());
            }

            if (authRepository.AdminAlredyExist(input.Email))
            {
                return(BadRequest("There is already a user with the specified email address"));
            }

            var adminToCreate = mapper.Map <Admin>(input);

            authRepository.CreateAdmin(adminToCreate, input.Password);
            authRepository.Save();

            var adminToCopy   = authRepository.GetAuthAdmin(input.Email, input.Password);
            var adminToReturn = mapper.Map <AdminDto>(adminToCopy);

            adminToReturn.Token = authRepository.GetToken(adminToCopy);
            return(Ok(adminToReturn));
        }