Ejemplo n.º 1
0
        public async Task <IActionResult> Register(CustomerForRegisterDto customerForRegisterDto)
        {
            //Validate user

            customerForRegisterDto.Customername = customerForRegisterDto.Customername.ToLower();
            //Check whether user with username exists or not
            if (await _repo.CustomerExists(customerForRegisterDto.Customername))
            {
                return(BadRequest("Username already exists"));
            }

            //Create the user without hashed password to create
            var customerToCreate = new Customer
            {
                Customername = customerForRegisterDto.Customername
            };

            var customer = await _repo.Register(customerToCreate, customerForRegisterDto.Password);

            return(StatusCode(201));
        }