Ejemplo n.º 1
0
        public async Task <IActionResult> Register([FromForm] UserRegistrationGeneralRequest UserModel)
        {
            if (UserModel.UserRole == null)
            {
                throw new UserRegistrationException("user registration information should have a role", true);
            }

            //validaty

            switch (UserModel.UserRole)
            {
            case "IMPORTER":
                var importerDto = _mapper.Map <ImporterDto>(UserModel);
                return(Ok(_mapper.Map <ImporterRegistrationResponse>(await _userRegistrationService.registerImporter(importerDto))));

            case "SUPLIER":
                var suplierDto = _mapper.Map <SuplierDto>(UserModel);
                return(Ok(_mapper.Map <SuplierRegistrationResponse>(await _userRegistrationService.registerSuplier(suplierDto))));

            case "TEAMWORK":
                var teamWorkDto = _mapper.Map <TeamWorkDto>(UserModel);
                return(Ok(_mapper.Map <TeamWorkRegistrationResponse>(await _userRegistrationService.registerTeamWork(teamWorkDto))));
            }
            return(BadRequest(new { message = "user role should be [ Importer, Suplier, TeamWork ]" }));
        }